dev-master
9999999-devSymfony DoctrineBundle
The Requires
- php >=5.3.2
- symfony/framework-bundle >=2.1,<3.0
Symfony DoctrineBundle
CodeMemeDaemonBundle is a wrapper for the PEAR library System_Daemon which was created by Kevin Vanzonneveld., (*1)
This will enable you to install the symfony bundle and easily convert your Symfony2 console scripts into system daemons., (*2)
pcntl is required to be configured in your PHP binary to use this. On my Ubuntu server I was able to install pcntl easily with the following command:, (*3)
sudo apt-get install php-5.3-pcntl-zend-server
System_Daemon is a PHP class that allows developers to create their own daemon applications on Linux systems. The class is focussed entirely on creating & spawning standalone daemons, (*4)
More info at:, (*5)
Place CodeMeme\Daemonbundle in your src directory and do the following:, (*6)
add the bundle to your deps configuration, (*7)
[CodeMemeDaemonBundle] git=http://github.com/CodeMeme/CodeMemeDaemonBundle.git target=/bundles/CodeMeme/Bundle/CodeMemeDaemonBundle
Add the following to your autoload.php file:, (*8)
$loader->registerNamespaces(array( //... 'CodeMeme' => __DIR__.'/../vendor/bundles', ));
Add The CodeMemeDaemonBundle to your kernel bootstrap sequence, (*9)
public function registerBundles() { $bundles = array( //... new CodeMeme\Bundle\CodeMemeDaemonBundle\CodeMemeDaemonBundle(), ); //... return $bundles; }
By Default, system daemons have a sensible configuration. If you need to change any configuration setting , you could do it by adding this configuration to your project config. Only the values that need to be changed should be added, the bundle extension will merge your daemon configs into its defaults., (*10)
app/config.yml #CodeMemeDaemonBundle Configuration Example code_meme_daemon: daemons: #creates a daemon using default options example: ~ #an example of all the available options explicitexample: appName: example appDir: %kernel.root_dir% appDescription: Example of how to configure the DaemonBundle logLocation: %kernel.logs_dir%/%kernel.environment%.example.log authorName: Jesse Greathouse authorEmail: jesse.greathouse@gmail.com appPidLocation: %kernel.cache_dir%/example/example.pid sysMaxExecutionTime: 0 sysMaxInputTime: 0 sysMemoryLimit: 1024M appUser: apache appGroup: apache appRunAsGID: 1000 appRunAsUID: 1000
You can run the daemon as a different user or group depending on what is best for your application. By default it will resolve the user and group of the user who is running the daemon from the command console, but if you want to run as a different user you can use the appUser, appGroup or appRunAsGID, appRunAsUID options. Remember if you need to run as a different user you must start the daemon as sudo or a superuser., (*11)
To find out the group and user id of a specific user you can use the following commands., (*12)
jesse@picard:~/ninethousand.org$ id -u www-data jesse@picard:~/ninethousand.org$ id -g www-data
The Following links are examples of how to use a system daemon in an example project, (*13)
Once you have Daemonized your symfony Console Commands, you can simply run them from the command line like so:, (*14)
jesse@picard:~/codememe$ php app/console jobqueue:start jesse@picard:~/codememe$ php app/console jobqueue:stop jesse@picard:~/codememe$ php app/console jobqueue:restart
Symfony DoctrineBundle