php npm,php – Laravel中NPM,Composer和Bower的区别?

所以在Laravel有Composer,NPM和Bower,我知道他们都是deoendancy经理.

Composer – 这似乎关注PHP依赖关系,包列表是composer.json的内容控制器.要安装软件包,您可以添加到此文件或运行php composer install< package>.

NPM – 这似乎专注于JavaScript依赖,但也有一个疯狂的包. npm install安装的软件包由package.json文件的内容决定.

鲍尔 – 据我所知,这是针对前端套餐的?

如果你愿意,你可以在Laravel中使用所有这三个,但是如果通过npm和composer这两个库可用,你为什么要使用另一个?

例如,在Laravel的安装中,它们有两个文件:

> app.js – 应用程序的主要js文件

> bootstrap.js – app.js中包含的文件,用于引入某些依赖项

这是我在resources / js中的bootstrap.js的内容

window._ = require('lodash');

window.Popper = require('popper.js').default;

/**

* We'll load jQuery and the Bootstrap jQuery plugin which provides support

* for JavaScript based Bootstrap features such as modals and tabs. This

* code may be modified to fit the specific needs of your application.

*/

try {

window.$= window.jQuery = require('jquery');

require('bootstrap');

require('slick-carousel');

require('isotope-layout/dist/isotope.pkgd.min.js');

require('tablesorter/dist/js/jquery.tablesorter.combined.min.js');

}

catch (e) {}

/**

* We'll load the axios HTTP library which allows us to easily issue requests

* to our Laravel back-end. This library automatically handles sending the

* CSRF token as a header based on the value of the "XSRF" token cookie.

*/

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**

* Next we will register the CSRF Token as a common header with Axios so that

* all outgoing HTTP requests automatically have it attached. This is just

* a simple convenience so we don't have to attach every token manually.

*/

let token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {

window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;

} else {

console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');

}

/**

* Echo exposes an expressive API for subscribing to channels and listening

* for events that are broadcast by Laravel. Echo and event broadcasting

* allows your team to easily build robust real-time web applications.

*/

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({

// broadcaster: 'pusher',

// key: process.env.MIX_PUSHER_APP_KEY,

// cluster: process.env.MIX_PUSHER_APP_CLUSTER,

// encrypted: true

// });

在app.css我有这个:

/*

* This file takes all of the styling we need and compiles it into one nice CSS file.

* You'll notice you can pull in anything from the node_modules folder use a Tiddle (~)

*/

@import '~bootstrap/dist/css/bootstrap.min.css'; // Bootstrap 3.3.7 CSS

@import '~slick-carousel/slick/slick.css'; // Slick Carousel base CSS

@import "variables"; // Sass Variables

@import "partials/typography"; // All from this point are from the partials folder

@import "partials/mixins";

@import "partials/helpers";

@import "partials/navigation";

@import "partials/breadcrumb-bar";

@import "partials/welcome-box";

@import "partials/form-box";

@import "partials/content-box";

@import "partials/carousels";

@import "partials/tables";

@import "partials/interactions-row";

@import "partials/downloads-area";

@import "partials/articles-events";

@import "partials/biography-pages";

@import "partials/grid";

@import "partials/footer";

@import "partials/steve-custom.scss";

实际上真正抛弃我的是:app.js怎么知道我在node_modules文件夹中引用文件夹,app.css怎么知道我只是通过使用〜来引用Bootstrap?

为什么我不必指定绝对路径?

一般的经验法则是,JavaScript相关项通常来自npm,而PHP依赖项来自作曲家?

我的困惑是因为我正在查看一个名为Laravel Full Calendar的软件包,它的样式和JS代码似乎是通过npm提取的,但它的PHP依赖部分是从Composer中提取的?

这是正常的行为吗?

我觉得这里有很多问题,但我觉得Laracasts真的没有解释这些包管理器的实际用法.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值