Code Compiler

Code package is a regular php-file including the source code of some system classes. A class (class file) can be included into a single package only. Package usage mode is activated in the system/config/main.php file using the usePackage property, the useMap command being executed too, as a package is identified with the use of classes map.

The developer defines which libraries and system classes are to be used constantly or in a group and thus, creates code packages containing sets of classes. Source code compilation is performed by clicking the ‘Compile packages’ button, the map of classes being built at the same moment.

There is no need writing your own scripts compiling the code into one file, moreover, it is not always helpful. Our tool allows to download only the code, which is essential for the request processing. This reduces the number of costly ‘require’ operation, on the one hand, and saves RAM and processor resources, on the other hand.

The idea of package compilation is quite easy. When a class is requested, Autoloader looks is up in the map (hash), locating it in the file system and associating it with this or that package. If the class is included into a package, the whole package gets connected. Otherwise, a single file is connected. If the class is not found in the map (the map may be obsolete, for instance), Autoloader is looking for the class file in the file system as per the paths defined.

Such an approach allows to increase the system performance by many times and reduces the amount of downloaded code.

Package management interface


The left side of the interface shows the list of packages, which contains the information on the package name, number of included files, active/ not active status and actual/ outdated status. If the source code has been modified and the package was not recompiled, a notification icon will show up requesting you to recompile the package.

The right side of the interface shows the list of files in a package and allows to change the order of their connection, which is very important when forming a package. Incorrect order setup will lead to a fatal error when using the package.

The Compile lang button launches compilation of lang files for JavaScript.

The ‘Compile packages’ button runs compilation of packages and classes map.

The map of classes is necessary for locating class files and reduces the load on the file system when performing the autoload search. Autoloading classes through the map may be performed in two modes configured in the main configuration file (system/config/main.php):

  • ‘only_map’=>true - searching through the map of classes. This mode allows for downloading only the classes specified in the map. The mode is a little bit more effective, however, it is important to keep the map up-to-date;
  • ‘only-map’=>false - a mixed mode: the class is first being looked for in the map and if the class is not found, the search for it is run through the file system.

The main principle one should remember: the package should contain the files, which are to be used together, whereas the package should not be overloaded with extra data, as this may lead to the fall in performance.

To define the list of files to be included into the package, use the Debug:: getStats method, which shows information on the connected files as well. The list of files connected by Autoload may be viewed separately.

The method is called in the index.php file with the development mode (‘development’=>true) and the debug panel (‘debug’_panel=>true) being on. The method is called without parameters by default, the panel shows the basic data only. To display more detailed information, use the following parameters when calling the method:

  1. $showCacheQueries = true   - show data on cache requests;
  2. $showQueries = true  - show the list of database requests;
  3. $showAutoloaded = true – show the list of autoloaded classes;
  4. $showInclided = true - show the list of connected files.