ubc /ltcommons-bundle
Symfony 2 的 LtCommons 包
0.1.1
2016-04-22 08:32 UTC
Requires
- php: >=5.3.3 <7
- symfony/event-dispatcher: 2.8.4
- symfony/filesystem: 2.8.4
- symfony/http-foundation: 2.8.4
- symfony/http-kernel: ~2.2
- ubc/ltcommons: ~0.1.1
Requires (Dev)
- phpunit/phpunit: 4.3.*
- symfony/dependency-injection: ~2.3
This package is not auto-updated.
Last update: 2024-09-25 13:14:30 UTC
README
安装
composer require ubc/ltcommons-bundle
使用方法
与 Symfony 2 一起使用
首先,启用 Bundle
// app/AppKernel.php class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ..., new UBC\LtCommonsBundle\LtCommonsBundle(), ); // ... } }
然后,在 app/config_*.yml 中的 Configuration
部分添加配置
使用 DI 容器
require 'vendor/autoload.php'; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; // Bootstrap the JMS custom annotations for Object to Json mapping \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace( 'JMS\Serializer\Annotation', dirname(__FILE__).'/vendor/jms/serializer/src' ); $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); $container->registerExtension(new \UBC\LtCommons\UBCLtCommonsExtension()); $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); $loader->load('config.yml'); $container->compile(); $codes = $container->get('ubc_lt_commons.service.department_code')->getDepartmentCodes();
配置
ubc_lt_commons: providers: sis: base_url: http://sisapi.example.com auth: module: auth2 rpc_path: /auth/rpc username: service_username password: service_password service_application: service_app service_url: https://www.auth.stg.id.ubc.ca http_client: Guzzle serializer: JMS xml: path: /path/to/data serializer: JMS