Blog |

drapeko

@author drapeko

Archive for the ‘autoloading’ tag

Overview of PHP Intelligencer 2.2

without comments

Short overview of 2.2 Intelligencer version enhancements.

New features

Last in Queue

“Last in Queue” behavior is basically an attempt to fight with very aggressive autoloaders (like symfony has) which aim to be the last in the queue by re-registering itself. “Last in Queue” behavior means that the manager will register itself once again if it’s not the last in the queue. You will have an ability:

* to specify number of attempts
* whether to do it only once or every time a new class is loaded

Two circles

“Two circles” behavior is devised to fight with unnecessary intelligencer cache invalidations and scanning. The first circle: go through all intelligencers; if the intelligencer is cacheable, load from cache. If the first attempt is unsuccessful the second circle takes place: go through all the cacheable intelligencers, invalidate cache and ask to load the class once again.

Cache for Templates

Templates, the same as Rules, will have an ability to cache the results. The good news is that templates will cache and invalidate particular classes not a list of them.

Persistent Cache improvements

Persistent cache will have an option to create all the subdirs that are missing.

This is a preliminary plan. The future updates can be found in Overview of Intelligencer 2.2

  • Share/Save/Bookmark

Written by rdrapeko

May 4th, 2010 at 2:53 pm

PHP Intelligencer released – manage your autoloading

with 2 comments

Intelligencer was released couple of days ago and hosted on google code.

Why should you use Intelligencer?

  • You want to scan the contents of files and find all classes inside them. The framework provides the powerful instructions for searching with the cache support.
  • You want to load the files according to the templates (e.g. Zend autoloading approach or Java class naming conventions)
  • You want autoloaders to be prioritized
  • You want your code to be independent from the locations of the sources

This framework is designed to prioritize and manage your class loadings.  There are two very powerful built-in itnelligencers: rules and templates. They are based on two different loading ideas. Basically, if you want the intelligencer to scan the files for the classes, use the rules. If you are able to create a path to the class without scanning the files (like Zend autoloading approach or Java naming conventions)

I will give you a short example of the code. The example below demonstrates how Rules Intelligencer works:

// Every time an attempt to load the class is made you want the
// intelligencer to check the cache and try to load from it.
// If an attempt is unsuccessful, the cache should be invalidated and #
// the files should be rescanned. 

    itManager::getInstance()
        ->setIntelligencerAndCreate(new itRulesIntelligencer())
            ->setCache(new itPersistentCache('cache.php'))
            ->setRulesAndCreate(new itComplexRules())
                ->setPrefix(dirname(__FILE__).'/drapeko/home/')
                ->plusDir('JustClass')
                ->getIntelligencer()
            ->control();

I hope you enjoyed it. Please visit official page http://code.google.com/p/intelligencer and find documentation and many useful examples.

  • Share/Save/Bookmark

Written by rdrapeko

April 26th, 2010 at 7:21 am

PHP Intelligencer, tiny autoload framework

with one comment

Several months ago I wrote an article that included several interesting examples of __autoload function, some autoloading approaches and a tiny script that is able find interfaces/classes and generate arrays of associations among these classes/interfaces, their locations and extended/included classes/interfaces.

http://wp.drapeko.com/2009/03/28/autoloading-in-php/

I widely use this script and I’ve found it really convenient.  I don’t have to think anymore of how to store my classes, what is the structure of the project etc. All this work is done by this script.

But… I have to launch it manually.

I’ve decided to go further and began to create a tiny framework called Intelligencer. This framework will extend functionality of the autoload generator script.

Some Intelligencers features:

  1. It is very tiny and does not depend on other frameworks and external libraries. It’s very easy to integrate it.
  2. It has an ability to store and control inheritance associations and relations between classes/interfaces and their locations.
  3. If something has changed Intelligencer will automatically regenerate (if necessary) lists of associations. It’s really very useful in the development stage.
  4. Intelligencer has a huge number of config settings. It’s flexible.
  5. Intelligencer supports environments. You can easily create your custom environments and switch between them.
  6. You can create several Intelligencers that will be responsible for different parts of your application.
  7. You can work with Intelligencer both on config level and API level.

If you use it, it will do all work for you. It’s an open source. Location -  sourceforge.

The first release will come very soon.

  • Share/Save/Bookmark

Written by rdrapeko

May 20th, 2009 at 10:37 pm

Autoloading in PHP

with 18 comments

computer_mainHave you ever been faced with autoloading in PHP? Are you a newbie? Do you think you understand the nature of autoloading? This article is for you. This article will take approximately 25-35 min.
This article:

  1. Asks you: what is an autoloading? Do you really understand how __autoload() function works?
  2. Examines several autoloading approches
  3. Suggests a script that scans folders for classes and interfaces and generates array of associations between classes and their locations.

Autoloading/Dependency generator: download (4.6 KB) 07 05 2009 →, description

Examples for this article: download (4.0 KB) →, description ↓

Read the rest of this entry »

  • Share/Save/Bookmark

Written by rdrapeko

March 28th, 2009 at 6:29 am

Promotions (coming soon)