Download the PHP package jfloff/djjob-zf2 without Composer

On this page you can find all versions of the php package jfloff/djjob-zf2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package djjob-zf2

h1. DJJob

p. DJJob allows PHP web applications to process long-running tasks asynchronously. It is a PHP port of "delayed_job":http://github.com/tobi/delayed_job (developed at Shopify), which has been used in production at SeatGeek since April 2010.

p. Like delayed_job, DJJob uses a @jobs@ table for persisting and tracking pending, in-progress, and failed jobs.

h2. Requirements

h2. Setup

bc. mysql db < jobs.sql

p. The @jobs@ table structure looks like:

bc. CREATE TABLE jobs ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, handler TEXT NOT NULL, queue VARCHAR(255) NOT NULL DEFAULT 'default', attempts INT UNSIGNED NOT NULL DEFAULT 0, run_at DATETIME NULL, locked_at DATETIME NULL, locked_by VARCHAR(255) NULL, failed_at DATETIME NULL, error TEXT NULL, created_at DATETIME NOT NULL ) ENGINE = INNODB;

p. Tell DJJob how to connect to your database:

bc. DJJob::configure("mysql:host=127.0.0.1;dbname=djjob_test;port=3306", array('mysql_user' => "root", 'mysql_pass' => "topsecret"));

p. If you're using mysql, you'll need to pass the database credentials separately. Otherwise, you can provide those in the connection string, see "http://stackoverflow.com/questions/237367/why-is-php-pdo-dsn-a-different-format-for-mysql-versus-postgresql":http://stackoverflow.com/questions/237367/why-is-php-pdo-dsn-a-different-format-for-mysql-versus-postgresql for an explanation.

h2. Usage

p. Jobs are PHP objects that respond to a method @perform@. Jobs are serialized and stored in the database.

bc.. class HelloWorldJob { public function __construct($name) { $this->name = $name; } public function perform() { echo "Hello {$this->name}!\n"; } }

DJJob::enqueue(new HelloWorldJob("delayed_job"));

p. Unlike delayed_job, DJJob does not have the concept of task priority (not yet at least). Instead, it supports multiple queues. By default, jobs are placed on the "default" queue. You can specifiy an alternative queue like:

bc. DJJob::enqueue(new SignupEmailJob("[email protected]"), "email");

p. At SeatGeek, we run an email-specific queue. Emails have a @sendLater@ method which places a job on the @email@ queue. Here's a simplified version of our base @Email@ class:

bc.. class Email { public function __construct($recipient) { $this->recipient = $recipient; } public function send() { ...do some expensive work to build the email: geolocation, etc.. ...use mail api to send this email } public function perform() { $this->send(); } public function sendLater() { DJJob::enqueue($this, "email"); } }

p. Because @Email@ has a @perform@ method, all instances of the email class are also jobs.

h2. Running the jobs

p. Running a worker is as simple as:

bc. $worker = new DJWorker($options); $worker->start();

p. Initializing your environment, connecting to the database, etc. is up to you. We use symfony's task system to run workers, here's an example of our jobs:worker task:

bc.. class jobsWorkerTask extends sfPropelBaseTask { protected function configure() { $this->namespace = 'jobs'; $this->name = 'worker'; $this->briefDescription = ''; $this->detailedDescription = <<<EOF The [jobs:worker|INFO] task runs jobs created by the DJJob system. Call it with:

[php symfony jobs:worker|INFO] EOF; $this->addArgument('application', sfCommandArgument::OPTIONAL, 'The application name', 'customer'); $this->addOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'); $this->addOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'); $this->addOption('queue', null, sfCommandOption::PARAMETER_REQUIRED, 'The queue to pull jobs from', 'default'); $this->addOption('count', null, sfCommandOption::PARAMETER_REQUIRED, 'The number of jobs to run before exiting (0 for unlimited)', 0); $this->addOption('sleep', null, sfCommandOption::PARAMETER_REQUIRED, 'Seconds to sleep after finding no new jobs', 5); }

protected function execute($arguments = array(), $options = array()) { // Database initialization $databaseManager = new sfDatabaseManager($this->configuration); $connection = Propel::getConnection($options['connection'] ? $options['connection'] : '');

$worker = new DJWorker($options);
$worker->start();

} }

p. The worker will exit if the database has any connectivity problems. We use "god":http://god.rubyforge.org/ to manage our workers, including restarting them when they exit for any reason.

h3. Changes


All versions of djjob-zf2 with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
zendframework/zendframework Version 2.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jfloff/djjob-zf2 contains the following files

Loading the files please wait ...