Содержание

Symfony YAML Configuration Reference

The autoload.yml configuration file

In this article we assume that you are familiar with The YAML Format and Configuration File Principles.

The autoload.yml configuration determines which directories need to be autoloaded by symfony. Each directory is scanned for PHP classes and interfaces. The autoload.yml configuration file is cached as a PHP file; the process is automatically managed by the sfAutoloadConfigHandler class.

autoload:
  config_name:
    name:            description
    path:            path_to_autoload
    recursive:       <true | false>
    exclude:         [directory1, directory2, ...]
    prefix:          <true | false>
    files:           [file1, file2, ..]
    ext:             php_class_extension

Autoload configuration options

autoload

The autoload.yml file must start with an autoload key and list the locations where symfony should look for classes.

autoload > config_name

Defines configuration name. Each configuration has a name and must be set under a key with that name. It allows for the default configuration to be overridden.

autoload > config_name > name

Defines a path description. It will appear as a comment in config_autoload.yml.php.

autoload > config_name > path

Defines the directory from which symfony should autoload files. A path can contain wildcards and use the file path parameters defined in the configuration classes. If you use these parameters in the configuration file, they must appear in uppercase and begin and end with %. By default, classes stored in the following directories in your projects benefit from the autoloading automatically:

autoload > config_name > recursive

Specifies whether to look for PHP classes in sub-directories. Possible values: <true | false>

autoload > config_name > exclude

Defines an array of directory names to exclude from the search. For instance, if you embed a large library within your project under the lib/ directory, and if it already supports autoloading, you can exclude it from the symfony default autoloading system to benefit from a performance boost by modifying the project autoload configuration:

autoload:
  project:
    name:           project
    path:           %SF_LIB_DIR%
    recursive:      true
    exclude:        [model, symfony, vendor/large_lib]

The lib/vendor/symfony/ directory is excluded by default, as symfony uses a different autoloading mechanism for core classes.

autoload > config_name > prefix

Set to true if the classes found in the path should only be autoloaded for a given module. Possible values: <true | false> Default: false

autoload > config_name > files

Defines an array of files to explicitly parse for PHP classes.

autoload > config_name > ext

Defines the extension of PHP classes. Default: php