次のようなものを探しています: http://knplabs.com/blog/give-your-projects-a-gaufrette ありがとうございます。
1 に答える
4
Gaufretteを使用するだけで、私も使用します (ZF2 プロジェクトでも)!
php composer.phar require knplabs/gaufrette:0.1.*
その後、アプリケーション内の任意の場所で使用でき、最終的には次のように定義してサービスとして使用できますYourNamespace\Module#getServiceConfig
。
namespace YourNamespace;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Gaufrette\Filesystem;
use Gaufrette\Adapter\Local as LocalFs;
class Module implements ServiceProviderInterface, ConfigProviderInterface
{
public function getConfig()
{
return array(
'your_namespace' => array(
'filesystem' => array(
'base_path' => 'data/files',
),
),
);
}
public function getServiceConfig()
{
return array(
'factories' => array(
'YourNamespace\Filesystem' => function (ServiceLocatorInterface $sl) {
$config = $sl->get('Config');
$basePath = $config['your_namespace']['filesystem']['base_path'];
return new Filesystem(new LocalFs($basePath, true));
},
),
);
}
}
YourNamespace\Filesystem
その後、すべてのアプリケーションでサービスを使用できます。
Symfony\Filesystem
また、ファイルの移動/コピー/チェック操作を処理するために と組み合わせて使用します。ZF2 アプリケーションで使用するために、Zend Framework 2 からすべてを取得する必要はありません。
于 2013-02-27T11:15:00.820 に答える