问题
How to publish package assets? I've found a tutorial here: http://laravel-recipes.com/recipes/279
But when I tried to publish assets from my workbench, I get this error:
[RuntimeException]
Unable to publish assets.
asset:publish [--bench[="..."]] [--path[="..."]] [package]
My command code is:
php artisan asset:publish --bench=Mypackage
How can I get my package assets to be published.
Thank you.
回答1:
When you want to publish assets that are developed and stored in your workbench you should use the --bench
flag. In your case you want to publish a package in the vendor folder then provide "myVendor/myPackage".
Publishing assets from a vendor package
php artisan asset:publish "vendor/package"
Publishing assets from a workbench package
php artisan asset:publish --bench="vendor/package"
回答2:
I'll give an example with Twitter Bootstrap Package.
If you want to publish your assets in the folder "public/packages" :
php artisan asset:publish --path="vendor/twitter/bootstrap/dist"
If you want to publish your assets in the folder "public/" :
php artisan asset:publish --path="vendor/twitter/bootstrap/dist" "../"
回答3:
You use the Workbench to prepare your own package for use in Laravel.
There is a directory structure for where to place your files:
/src
/Vendor
/Package
PackageServiceProvider.php
/config
/lang
/migrations
/views
/tests
/public <---- the folder in question here
When preparing your package, any files that need to be accessible from the web server like imgs/css/js files (or assets
as they are typically called in web apps) are put here.
Then when you enter the command:
php artisan asset:publish --bench=Mypackage
it will deploy those files into
/approot
/public
/vendor/package/
more info here: http://laravel.com/docs/packages
回答4:
When I wanted to copy Twitter Bootstrap (SASS version) for me worked only:
php artisan asset:publish --path="vendor\twbs\bootstrap-sass\assets" .
it copied assets folder content (3 directories) to public/packages
.
When I had no .
at the end there was no message and nothing was copied.
And when I omitted assets
directory in the command the whole vendor\twbs\bootstrap-sass
directory content was copied to public
directory what is of course unnecessary
来源:https://stackoverflow.com/questions/21596140/laravel-4-publishing-a-packages-assets