uwej711/pimplex

Pimple 的 Symfony 组件提供者

dev-master 2013-11-11 12:02 UTC

This package is auto-updated.

Last update: 2024-09-15 00:10:18 UTC


README

此库包含用于 Pimple 的 ServiceProviders,以便使用 Symfony 2 组件。

提供者的代码是从 Silex 拿来的,并修改为与 plain Pimple 一起工作,用于不需要完整(微)框架的场景,例如向现有 PHP 应用程序添加 Symfony 组件。请参阅 LICENSE 文件。

使用方法

<?php
require_once __DIR__.'/vendor/autoload.php';

$container = new Pimplex\Container();
$container->register(new Pimplex\ServiceProvider\TwigServiceProvider());

container['twig.path'] = 'your-template-path';

echo $container['twig']->render('hello.twig', array('name' => 'World');

或者如果您使用 plain Pimple

<?php
require_once __DIR__.'/vendor/autoload.php';

$container = new \Pimple();
$twigServiceProvider = new Pimplex\ServiceProvider\TwigServiceProvider();
$twigServiceProvider->register($container);

container['twig.path'] = 'your-template-path';

echo $container['twig']->render('hello.twig', array('name' => 'World');