Download the PHP package mtymek/class-dumper without Composer
On this page you can find all versions of the php package mtymek/class-dumper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mtymek/class-dumper
More information about mtymek/class-dumper
Files in mtymek/class-dumper
Package class-dumper
Short Description Creates single file containing multiple classes, to speed up application bootstrap.
License BSD-2-Clause
Informations about the package class-dumper
Class Dumper
Creates single file PHP containing multiple classes, to speed up application bootstrap.
Usage
Commandline script
First, create configuration file that lists all files you want to merge. You don't need to worry about class order, nor about adding required interfaces or parent classes - they will be added automatically to merged file.
Config file is simple PHP file, returning array of class names:
Next, use dump-classes.php
script to generate cached file:
When class cache is generated, you can include it in your application entry point:
You can automate generation using composer
by adding post-install and post-update hooks
to composer.json
file:
PHP
Alternatively, cached class file can be generated in your PHP script:
Minifing merged file
ClassDumper can reduce size of emitted file by stripping all whitespace and comments.
It can be triggered from commandline by adding --strip
switch:
Using in PHP:
Generating config files
You can easily generate configuration file based on currently included files in your application. In order to do it, add following lines after your application bootstrap (ideally somewhere before routing starts):
This will save list of all included classes into config.php
file. You may want to edit configuration
file manually before using it in your application - see "Limitations" section below.
After creating the config file, remove above lines.
Limitations
Not every class can be cached using Class Dumper
.
- class dump will end up in different directory than merged classes. Classes using constants
like
__DIR__
or__FILE__
will likely not work correctly. - when using with "--strip" options, all comments - including annotations - will be stripped out. This will prevent annotation parser from working, if used on cached classes.
TODO
- throw exception when class does not exist
- warn if class contains
__DIR__
or__FILE__
constants - output/log statistics
- fix
__DIR__
constants
All versions of class-dumper with dependencies
zendframework/zend-code Version ~2.4
zfcampus/zf-console Version ~1.0