cobaia/

spork-provider

Spork 在 Silex 或 Cilex 中使用的依赖注入提供者

dev-master 2012-08-26 14:23 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:02:20 UTC


README

Spork 的依赖注入提供者,可用于 Spork,在 SilexCilex 中使用。

如何在 Silex 中使用

<?php

	$app->register(new Cobaia\Spork\Provider\Silex\SporkProvider());
	$app['spork']->fork(function() {
    	// do something in another process!
    	return 'Hello from '.getmypid();
	})->then(function(Spork\Fork $fork) {
    	// do something in the parent process when it's done!
    	echo "{$fork->getPid()} says '{$fork->getResult()}'\n";
	});

如何在 Cilex 中使用

<?php

	$app->register(new Cobaia\Spork\Provider\Cilex\SporkProvider());
	$app['spork']->fork(function() {
    	// do something in another process!
    	return 'Hello from '.getmypid();
	})->then(function(Spork\Fork $fork) {
    	// do something in the parent process when it's done!
    	echo "{$fork->getPid()} says '{$fork->getResult()}'\n";
	});