Autoloading is the term used to describe the process where class files are loaded at the first http request (and cached for subsequent requests). The main benefit of autoloading is that  you don’t need to add a bunch of ‘require_once’ calls to your classes to get things working, they are all autoloaded for you. Some may see this autoloading as ‘bloat’, but if strategically cached, it does allow for easier coding within the symfony framework.

Chances are you have some custom classes which are specific to your actual business needs. Rather than stuffing these custom classes in the core symfony directories (lib/model, lib/forms, lib/filters), which they don’t belong, you can create custom directories and then tell symfony about them so symfony can autoload them as if they were the core symfony directories.

Check out the following example:


custom_app: #Unique identifier for autoloading anything in given dir

  name:      Custom app classes #Something that makes sense to you

  ext:       php #You can load files with specific extensions

  path:      %SF_LIB_DIR%/app #The directory from which symfony should autoload files, in this case lib/app

  recursive: true #Whether to load files within nested dirs

As you can see, autoloading in symfony allows for flexible lib structures, which allows you to better structure your classes for faster development and easier maintenance.

Edit (2.16.11)

Thanks to Tix comment, you want to add autoload.yml files to /apps/<app_name>/config/autoload.yml

Edit (9.17.11)

Thanks to German Rumm’s comment, be sure that autoload: is the first line in your autoload.yml file.

Also, here is an actual example:

autoload:
  sfcustom_api:
    name:      Symfony specific custom apis
    ext:       php 
    path:      %SF_LIB_DIR%/MyCustom/api
    recursive: true