我对PHP和Laravel都比较新,现在遇到一个问题:我需要将最新版的Bootstrap CSS框架正确地安装到我的Laravel应用程序中。
在Bootstrap下载页面:http://getbootstrap.com/getting-started/#download
上面说可以使用composer通过以下语句完成安装:
composer require twbs/bootstrap
所以我尝试了一下,在我的控制台上获得了这个输出:
Andrea@Andrea-PC MINGW64 /c/xampp/htdocs/HotelRegistration
$ composer require twbs/bootstrap
Using version ^3.3 for twbs/bootstrap
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing twbs/bootstrap (v3.3.7) Downloading: 100%
Package illuminate/html is abandoned, you should avoid using it. Use laravelcollective/html instead.
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled services file has been removed.
前面的输出具体意味着什么?它成功了吗?我的疑惑是我找不到 bootstrap.css 文件在我项目的 .../resources/assets 目录里。
为什么?我错过了什么?如何在我的项目中使用Bootstrap?
编辑1:我看到Composer已经把Bootstrap放在了这个文件夹里:
.../vendor/twbs/bootstrap/dist/css/bootstrap.css
所以,按照这个SO链接:How to setup bootstrap after downloading via composer?
我尝试去做:
php artisan asset:publish --path="vendor/twbs/dist/css" bootstrap/css
我想将 vendor/twbs/dist/css 的内容作为资产发布,但收到以下错误信息:
to publich the content of the vendor/twbs/dist/css as an asset but I obtain this error message:
Andrea@Andrea-PC MINGW64 /c/xampp/htdocs/HotelRegistration
$ php artisan asset:publish --path="vendor/twbs/dist/css" bootstrap/css
[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "asset" namespace.
看起来资产语句不存在。
我该怎么办?
<link href="/css/app.css" rel="stylesheet">
添加到头标签中即可。这样就可以导入所有内容了。 - Vaibhavraj Roham