jalis/service-generator
Composer 安装命令:
composer require jalis/service-generator
包简介
Symfony2 Bundle for create services by command line
README 文档
README
This package contains a bundle to easily create basic services efficiently and without effort from command line.
The package add a new command line app/console generate:service that create all the config and code for a basic service:
- Modify the services.xml (only works for xml language only)
- Create a Lib Class
- Inject dependencies (Entity Manager)
Installation
Step 1: Install vendors
Installation depends on your version of Symfony:
Symfony 2.1.x: Composer
Composer is a project dependency manager for PHP. You have to list
your dependencies in a composer.json file:
{
"require-dev": {
"jalis/service-generator": "dev-master"
}
}
To actually install Service Generator in your project, download the composer binary and run it:
wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar
php composer.phar install
Symfony 2.0.x: bin/vendors.php method
If you're using the bin/vendors.php method to manage your vendor libraries,
add the following entries to the deps in the root of your project file:
[JalisServiceGeneratorBundle]
git=https://github.com/javijalis/JalisServiceGeneratorBundle.git
target=/bundles/Jalis/Bundle/ServiceGeneratorBundle
Next, update your vendors by running:
$ ./bin/vendors
Finally, add the following entries to your autoloader:
<?php // app/autoload.php $loader->registerNamespaces(array( // ... 'Jalis' => __DIR__.'/../vendor/bundles', ));
Step 2: Enable the bundle
Finally, enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Jalis\Bundle\ServiceGeneratorBundle\JalisServiceGeneratorBundle(), ); }
How to use:
Execute the command:
$ app/console generate:service
Follow the instructions:
Your service code must be written in Manager directory. This command helps you generate them easily. Each service is hosted under a namespace (like Acme/Bundle/BlogBundle). (which must have Bundle as a suffix). Bundle namespace: myFolder/Bundle/myBundle Your service must have a name for call it Service Name: example Your service need EntityManager? Do you need entity Manager in your service [no]? yes
After that, you only have to use the service where ever you want:
$my_service = $this->get('exampleManager');
The class for your code used in the service is in the folder BundleGiven/Manager/exampleManager.php
<?php namespace BundleGiven\Manager; use Doctrine\ORM\EntityManager; class exampleManager { protected $em; public function __construct(EntityManager $em){ $this->em = $em; } public function getInfo() { return "name: exampleManager"; } //... your code }
ToDo
- Option for create Twig extensions
- Add more options for inject more native services (monolog, mailer) and own services
- Refactor Command class code
- What about services in yml?
jalis/service-generator 适用场景与选型建议
jalis/service-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 309 次下载、GitHub Stars 达 1, 最近一次更新时间为 2013 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dependency injection」 「generator」 「Symfony2」 「service」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jalis/service-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jalis/service-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jalis/service-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A fast and intuitive dependency injection container.
Dependency injection container for the Monolith framework.
Http Microframework for Hack
Phalcon Model Generator
统计信息
- 总下载量: 309
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-01-03