geeh/snubbed
Composer 安装命令:
composer require geeh/snubbed
包简介
Generate snub class to get code completion for ZF2 in your favourite IDE
README 文档
README
ALPHA!!!
Snubbed
Create Snubs of Zend Framework 2 projects to make IDE integration much tighter
Installing
- Add
"geeh/snubbed": "dev-master"to youcomposer.jsonandcomposer update
Running
- use
php vendor/bin/snub.php <application config> <default controller class>- you can leave the parameters blank and it will default toconfig/application.config.phpandZend\Mvc\Controller\AbstractActionControllerwhich should be good enough for a standard skeleton application based projects - you'll see the Snubs created in the
.idefolder in the root of your project
Using
Controllers
- update your use statement where you import the basic controller in your controllers to use the Snubbed controllers instead - use the
askeyword to make it seamless is recommended:
namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class IndexController extends AbstractActionController { public function indexAction() { return new ViewModel(); } }
Becomes:
namespace Application\Controller; use Snub\SnubbedZendMvcControllerAbstractActionController as AbstractActionController; use Zend\View\Model\ViewModel; class IndexController extends AbstractActionController { public function indexAction() { return new ViewModel(); } }
You'll now have code completion in your controllers, including any controller plugins:
Views
Snubbed will also generate view snubs that give you code completion in the view, including your view helpers and view variables for each view. In the .ide/Snub/View directory, you'll find a class_map.php that will tell you which Snub you should use for each view template. You'll see that it's straightforward, and you'll soon be able to predict the filename.
To use the view Snubs, simply include an @var docblock at the beginning of your view file. Assuming your controller is:
class IndexController extends AbstractActionController { public function indexAction() { return new ViewModel( ['form' => new Form()] ); } }
Then in your view (in this case view\application\index\index.phtml), simply add the following under an opening <?php tag right at the top of the file:
<?php /* @var \Snub\View\ApplicationControllerIndexIndexAction $this */ ?>
Obviously, you need to replace the Snub class name with the classname that is suitable for this view file. You'll then get code completion in the view, including the view variables that you set in the action:
Note: There are some known problems at the moment that stop variable completion from happening. If, for example, your controller is protected by RBAC or ZfcUser authentication, then Snubbed won't be able to dispatch the controller from the command line, and therefore won't be able to analyise the output.
Helping
At this moment, the code is terrible, untested, but actually works. If you find there are errors in using this then please submit issues here so I can try and get them fixed. PLEASE PLEASE PLEASE
geeh/snubbed 适用场景与选型建议
geeh/snubbed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 geeh/snubbed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 geeh/snubbed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-30