4

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.

user1995781
  • 19,085
  • 45
  • 135
  • 236

4 Answers4

6

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"
sidneydobber
  • 2,790
  • 1
  • 23
  • 32
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Knowledge Craving Apr 21 '14 at 13:27
  • This is the answer! Can't make it any clearer then this. – sidneydobber Apr 22 '14 at 08:29
  • Normally when you are answering to something, it's nice to say what part of the code (in the question) was wrong, or what is that part of the question in particular that you're correcting. So in your answer, you can brief a little bit about why "`vendor/package`" is the main trick of the solution. – Knowledge Craving Apr 22 '14 at 08:51
3

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" "../"
victorkurauchi
  • 1,390
  • 18
  • 23
1

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

warspite
  • 622
  • 3
  • 12
1

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

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291