I am working on the Laravel project, and intend to use Vue.js as its client-side scripting. When I searched the internet, I found that I had to use the npm install command. My question is if I run the order, will it affect the project I'm working on?
For example, in the directory structure or variable section?
It will change only package.json and /node_modules folder (it will download vue.js last version package into this folder) in your root directory. But it won't affect your existing codebase until you don't use them via importing or accessing it. It is like installing a package with composer, but not using it. The downloaded package will stay in /vendor folder and package name in composer.json, composer.lock
Related
Is that possible to completely remove node_modules folder from laravel app and not using it?
My app doesn't require any npm packages and I'm not using echo or pusher or any other API's that requires npm packages, then
Is it OK to remove this unnecessary folder in my app or somehow laravel
needs it to work?
If your project doesn't require node packages then you can remove it, it's not necessary to run Laravel project. But if you're using VueJS, or NodeJS then you need it.
composer update not download node packages, it only installs packages in vendor folder, node_modules is different which includes node packages.
If you want to install node packages, then use npm install command to install it again.
Hope this will helps you!
It is safe to remove the folder. The normal workflow would be to compile all CSS and JS files before deployment and copy them to the public/ directory, rendering the node_modules/ obsolete for deployment.
If anything breaks after you removed it, you can still bring it back with npm install.
I have never used Composer, but I want to use PHPSpreadsheet package, and it is recommended that Composer is used.
I am on a MAC using XAMPP and Netbeans.
I have installed Composer, and I have run the following command to get and install the PHPSpreadsheet package.
php ../../Composer/composer.phar require phpoffice/phpspreadsheet
I am running this in my project folder, (hence the ../../ to where Composer.phar is located.
This downloads the files into a vendor folder in my project folder.
What should I do then? Do I need to keep it in the Vendor folder, or can I move into a folder of my choice?
Netbeans has Composer options in the menus, but as far as I can see, this is for creating dependencies rather than installing packages.
I know I am totally missing the point of Composer somewhere, but have spent hours just trying to get this work.
Many thanks
You should really start with the docs -> https://getcomposer.org/doc/01-basic-usage.md
You have to keep the vendor directory - this is where all dependencies are kept. If you require more packages - then they will be installed in that directory.
After requring the package you have to load it so the PHP will know all the classes. Composer comes with great autolader. It is located by default in vendor/autoload.php. So what you have to do now is to require this file in your project. After that all classes from composer packages will be loaded automaticaly each time you use them in the code :)
I hope this will help you with this great tool. Cheers.
To remove a package using the command "composer remove vendor/vendor" it works, the command dont shows any error. However the package files (classes, etc) are not removed from the folder of the project. Its necessary to remove manually the package fiels that are not removed with the remove command?
Just if you want to remove them from your disk.
If you are running in developer mode, i think that has no problem to let them there, because when you go to deploy your project a new fresh installation script will run with the information of your composer.json, if in your composer.json file don't have any entry with the 'vendor/package' which you want to remove, it will not be installed.
Commonly composer removes any packages that aren't in your composer.json package list fom the vendor folder.
Time ago, I installed a dependency on a Symfony project. It was the package mograine/calendar-bundle, but now this project doesn't exist anymore and has disappeared from github. It was a fork of another package with some modifications that I need for the project I'm working on.
Of course, I have a copy of the package (under vendor/mograine folder). But, currently I'm unable to run the composer install order, because this package doesn't exist.
And my question is: What can I do to solve this problem? Can I tell composer that this package is installed locally? If so, what should I do to install the package locally? Or I must create a github account and upload all the original files?
If its a normal symfony project, you can simply move it to your src folder resp. "copy past the namespace directories to the src directory" and remove it from the composer.json.
The src folder is autoloaded f.e.
"autoload": {
"psr-0": {
"": "src/"
}
Take care that the namespaces and pathes are correct.
Also see here: moving bundle from vendor to src directory
I have a PHP project, that uses composer for it's PHP dependencies and bower for it's front end dependencies. So basically I have a directory structure that looks something like this (a simplified version obviously):
/app
/bower_components
/public
/vendor
/foo
/bar
/src
bower.json
composer.json
bower.json
composer.json
gulpfile.js
As you can see, the php dependency has some front end dependencies of it's own, that are also managed with bower. However, when I run bower install from the root of my app, the bower file from inside my foo/bar dependency is ignored.
I do not want to build my front-end dependencies inside foo/bar in advance and just include those in my app using gulp, because foo/bar may have overlapping dependencies with my app (like jQuery or Bootstrap or something) and I obviously do not want to include those twice. And I also would prefer bower throwing an error when there are version conflicts for overlapping dependencies, rather then having to find out the hard way.
Ideally all my front end dependencies would end up in my root bower_components directory, both those from my app's bower.json, as well as those from vendor/foo/bar/bower.json. This way I can have gulp compile all those into a single (or probably a few) .js and .css file.
So the question is, is that possible? Can I have bower look at other bower.json files inside sub directories? Or is there a recommended way to automatically merge multiple bower.json files before bower is ran?
I have spent the last hour scouring the web for a good solution to this problem, but I can't seem to come up with anything. (If you know of a good blog post or resource on this topic, please do share!) All google gives me are some basic bower tutorials, that are not very helpful here. Am I really the first one to run into this problem, or is there something fundamentally wrong in the way I am trying to tackle the issue at hand?
One way to tackle this (and a way Symfony CMF uses now) is to create bower packages for your PHP dependencies. This means you create a front-end bower package from your bundle, the package only contains the bower.json file with the dependencies.
Now, in your application's bower.json file, you can specify these "virtual" bower packages as requirements and run bower install. For instance:
{
"dependencies": {
"php-foobar": "^1.3"
}
}
The composer plugins composer-extra-assets and composer-assets-plugin allow adding bower dependencies to composer.json.
composer-assets-plugin is implemented in pure php and turns bower packages into composer packages.
composer-extra-assets calls the "real" bower behind the scenes. It is installed (including the required nodejs) automatically though if you don't have it on your system.
Disclaimer: I'm the author of composer-extra-assets.