简体   繁体   English

Laravel 4:发布程序包的资产

[英]Laravel 4: Publishing a Package's Assets

How to publish package assets? 如何发布打包资产? I've found a tutorial here: http://laravel-recipes.com/recipes/279 我在这里找到了一个教程: 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. 谢谢。

When you want to publish assets that are developed and stored in your workbench you should use the --bench flag. 当您要发布已开发并存储在工作台中的资产时,应使用--bench标志。 In your case you want to publish a package in the vendor folder then provide "myVendor/myPackage". 在您的情况下,您想要在供应商文件夹中发布软件包,然后提供“ 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"

I'll give an example with Twitter Bootstrap Package. 我将通过Twitter Bootstrap Package给出一个示例。

If you want to publish your assets in the folder "public/packages" : 如果要在“ public / packages”文件夹中发布资产:

php artisan asset:publish --path="vendor/twitter/bootstrap/dist"

If you want to publish your assets in the folder "public/" : 如果要在“ public /”文件夹中发布资产:

php artisan asset:publish --path="vendor/twitter/bootstrap/dist" "../"

You use the Workbench to prepare your own package for use in Laravel. 您使用工作台准备自己的软件包以在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 / public <----这里有问题的文件夹

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. 准备软件包时,此处需要放置任何可从Web服务器访问的文件,例如imgs / css / js文件(或通常在Web应用程序中称为assets文件)。

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 此处提供更多信息: http : //laravel.com/docs/packages

When I wanted to copy Twitter Bootstrap (SASS version) for me worked only: 当我想复制Twitter Bootstrap(SASS版本)时,仅对我有效:

php artisan asset:publish --path="vendor\twbs\bootstrap-sass\assets"  .

it copied assets folder content (3 directories) to public/packages . 它将资产文件夹的内容(3个目录)复制到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 当我在命令中省略了assets目录时, vendor\\twbs\\bootstrap-sass整个vendor\\twbs\\bootstrap-sass目录内容复制到public目录中,这当然是不必要的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM