自动调用资产:publish --bench ="vendor/package"在开发中Laravel 4 [英] Automatically call asset:publish --bench="vendor/package" during development in Laravel 4
问题描述
我正在处理一个包装,确实需要能够触发
I'm working on a an package and I really need to be able to fire the
php artisan asset:publish --bench="vendor/package"
在开发过程中自动执行命令.
command automatically during development.
每次我对程序包中的JavaScript或CSS文件进行更改时,编写该命令都是非常耗时的.
It's very time consuming to write that command every time I do changes to my JavaScript or CSS files in my packages.
我试图通过服务提供商致电Artisan
I've tried to call Artisan in my service provider
public function boot()
{
Artisan::call('asset:publish', array('--bench' => 'arni-gudjonsson/webber'));
...
}
我知道了
ErrorException: Runtime Notice: Non-static method Illuminate\Foundation\Artisan::call() should not be called statically, assuming $this from incompatible context
Artisan是否设计为无法通过网络调用?有人有什么建议吗?
Is Artisan not designed to be called via the web? Does anybody have some advice?
推荐答案
您可以使用 Guard 来完成任务像这样.例如,这是我的Guardfile中的一部分,可在更改资产时自动从包中发布资产:
You can use Guard for tasks like this. For example, here is a portion from my Guardfile to automatically publish assets from a package whenever they are changed:
guard :shell do
watch(%r{^workbench/vendor/package/public/.+\..+$}) {
`php artisan asset:publish --bench="vendor/package"`
}
end
您还可以让它自动编译Sass,设置livereload等.看看
You can also have it automatically compile Sass, setup livereload, etc. Take a look at Jeffrey Way's screencast to get started.
这篇关于自动调用资产:publish --bench ="vendor/package"在开发中Laravel 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!