OK, because the work needs to start using YII2 directly, so will start YII2 code analysis and comparison, YII1 analysis will continue.
Yii Init Documentation
This is a command-line tool
First he gets two different configurations by reading the URL argv, which is to develop and produce two environments
Then read Stdn via PHP to get user selection, copy environment configuration to Web site root directory
More humane than the 1 version. We can customize the environment according to our own needs.
is still his entrance file yii.php, no change
Unlike before, he configured the environment and defined the input and output streams
It then loads an auto-load class, and Boostrap.
The running part of the framework, the configuration of application, which is originally controlled by the core file, is manually loaded.
But because of the original architectural reasons, basically makes the appearance does not have much big change
Look at his automatic loading file, originally here is to implement the normalized loading of PSR.
The file is then automatically loaded via a composer, which loads another class's auto-load function as a temporary load function
The PSR4 namespace class is initialized at the same time to load
Finally a file to facilitate, and then return the file name, but do not understand what this means
Here is the implementation of Yii for the Psr0 section, other detailed sections later look
Enter the Yii file, which is an inheritance class that allows us to generate our own appearance configuration,
Then we reset the automatic class load function,
It also contains a DI container and a class information hash table.
In addition to removing the control of application, the entire file changed the name of the created component, changed to object, more image and relevance, and improved the compatibility and extensibility of yii.
The application part of the constructor is simplified, at the same time more image is appropriate, first set the handle, using the general terminology of instance, more explicit yii as a desktop development on the Web extension.
Then the new state mode is used, and the part of the original registration component is placed in the PreInit,
In addition to the original BasePath validation, the PreInit section adds additional validation while simplifying the loading of the component information
The error handler is then set, and the exception is not handled here.
And then directly called his ancestral components, where the module does not inherit components directly, but adds serverlocal inheritance to add a dependency injection to the components, reducing the coupling, This can be seen as the use of a decorator's pattern.
yii2.0 Study and change comparison (i.)