src/vendor/symfony
with the latest one.git clone git: //github.com/symfony/symfony-sandbox.git sandbox cd sandbox / src / vendor rm -rf symfony git clone git: //github.com/symfony/symfony symfony
hello/
: directory named after the application and containing configuration files.src/
: all PHP code is stored here.web/
: web server root directory.index.php
controllers - for the production environment and index_dev.php
- for the development environment. In general, everything is as before, with one exception, here a useful check.php
script check.php
that allows you to check the environment for compliance with the system requirements of Symfony 2.0.run
method.hello/
application directory contains an application kernel class that extends the abstract Symfony\Foundation\Kernel
class and makes basic definitions. In particular, the root directory of the application is defined here, “bundles” are registered (which is what Symfony consists of and applications built on it now), paths to search for “bundles” are registered, Dependency Injection Container is created and routing rules are registered. Methods that create an IOC container and define routing rules in the default implementation load configuration files from the hello/
application directory. Here in the kernel class two important src/autoload.php
and src/vendor/symfony/src/Symfony/Foundation/bootstrap.php
needed for the kernel to work properly, in particular, an instance of the Symfony\Foundation\UnversalClassLoader
class is created in Symfony\Foundation\UnversalClassLoader
and set up paths for auto-uploading files with classes. Paths are defined by two methods registerNamespaces
- allowing you to specify paths for searching classes by their namespaces and registerPrefixes
- allowing you to specify file paths by class prefixes, for example Swift_
, Zend_
ie for classes written in the PHP version of the version below 5.3hello/console
file - an analogue of the symfony
file in symfony 1.x, i.e. tool allows you to perform various commands from the console.hello/cache
: for cachehello/logs
: for logshello/config
: for configuration filessrc/autoload.php
file already mentioned above and the directories are in the source directory src/
:src/Application
: contains the “bundles” of our web application, in this case HelloBundlesrc/Bundle
: contains third-party or shared “bundles” between several applications, in our case there is nothingsrc/vendor
: contains source code for third-party libraries, in our case it contains doctrine
, swiftmailer
, symfony
, zend
HelloBundle/Controller/HelloController.php
: application controllerHelloBundle/Resources
: bundle resources including templatesapps/
directory containing various applications using common code. In our case, this directory is not, but different applications can be created and can be done in a convenient way for us. For example, you can create application directories on the same level as src/
and web/
, i.e. as done in our case with the hello
application. We can add another application, for example bye
. Or we can simply add the class of the new application ByeKernel
to the hello/
directory hello/
setting the root directory of the application in it. By the way, no one forbids creating an apps/
directory in which to host applications. In general, in terms of directory structure, everything is very flexible.Symfony\Foundation\Bundle\KernelBundle
Symfony\Framework\WebBundle\Bundle
Symfony\Framework\ZendBundle\Bundle
Symfony\Framework\SwiftmailerBundle\Bundle
Symfony\Framework\DoctrineBundle\Bundle
Application\HelloBundle\Bundle
hello/config/
directory. In particular, there are:hello/config/config.yml
: general settingshello/config/config_dev.yml
: settings for the dev environmenthello/config/config_prod.yml
: settings for prod environmenthello/config/routing.yml
: routing rulesconfig_dev.yml
and config_prod.yml
files config_dev.yml
config_prod.yml
file config.yml
imports instruction, imports
is very convenient. If you open the file config.yml
, then it has settings for the connected "bundles".# hello / config / config.yml kernel.config: ~ web.web: ~ web.templating: ~
kernel.config
defines the settings for the “bundle”. Some bundles can have several entries, such as the WebBundle
, which has two entries, web.web
and web.templating
config_dev.yml
:# hello / config / config_dev.yml imports: - {resource: config.yml} web.debug: exception:% kernel.debug% toolbar:% kernel.debug% zend.logger: priority: info path:% kernel.root_dir% / logs /% kernel.environment% .log
Source: https://habr.com/ru/post/89134/
All Articles