Symfony Learning--catalogue and entrance

Source: Internet
Author: User

1 directory structure

The root directory is:

Appsrcvendorweb

Apps are some of the configuration files that are stored in your app, and if you have some configuration files or documents, you should store them in this area.

SRC is the PHP code that holds your project, PHP must be at least 5.3, because the concept of namespaces is used in Symfony.

Vendor is a directory that holds third-party code, which can be very large because Symfony uses the concept of third-party bundles in large numbers, even as a third-party bundle plugin.

The web is the information needed to hold a Web page, which can contain information such as js,css,html.

2 Concept of bundles

The concept of symfony is equivalent to the concept of SOA, where each module is responsible for providing a service that your business needs to provide, and then load the corresponding bundle into the business.

Symfony is a good way to achieve the independence of the module, each module is a bundle

The specific loading method is in the app/appkernel.php, this class later with a special article to learn it

3 with Nginx Build service

You can tell from the directory that the root of the server for Nginx is placed under the web

Then assign the location's default index to web/app.php or web/app_dev.php.

4 Portal File app.php basic framework:
12345678910111213141516171819 <?php use Symfony\Component\HttpFoundation\Request;   // 使用Request命名空间$loader = require_once __DIR__.‘/../app/bootstrap.php.cache‘;   // bootstrap的自加载文件,包括autoload等require_once __DIR__.‘/../app/AppKernel.php‘;   //bundle的加载 $kernel = new AppKernel(‘yjf‘, true);   // 核心类AppKernel$kernel->loadClassCache();   // 加载classCache$request = Request::createFromGlobals();  // 获取$_REQUEST$response = $kernel->handle($request);   // 处理请求,将request转化为response$response->send();   // 发送response$kernel->terminate($request, $response);  // response的后续操作
Here are a few places to look: require_once __dir__. ' /.. /app/bootstrap.php.cache '; What does this statement do?

One of the first functions of this file is to implement the autoload mechanism, followed by a cache mechanism.

What is the cache mechanism?

Symfony uses multiple third-party classes and bundles, and then each class is scattered across files. If the individual files are loaded into memory at the time of each request, there is no doubt that there are many IO operations.

The mechanism for caching is to centralize the classes used in a single file, and each request needs to be loaded with the required classes.

Of course this file will be very large, you can see the classes.php file in the app/cache/xxx after running.

App.php behind the $kernel->loadclasscache (); The statement is used to load the cache class file.

So, if you don't want to use the Symfony caching mechanism, you need to comment out the two statements.

Symfony Learning--catalogue and entrance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.