Getting Started With Laravel 4, Chapter 2: Composer All Over
Working with the command line
This section goes over how to open a terminal window, and introduces the cd command. It also gives the shortcut of typing cd in a terminal window, and then dragging the folder you want into the terminal window as a way of navigating to the correct folder.How does Composer work?
Composer is a command line tool that uses a json file to download and install packages.Installation
Unix (MacOS, Linux)
This might have been the easiest tutorial I have ever found. It just worked. The biggest caveat is to make sure you have PHP installed and added to your Path variable.Windows
These instructions seem easy to follow. I don't have a Windows pc to test on, so I can't say for certain. I think the hardest part, is making sure you have PHP installed.Creating a new Laravel application
Creating a new Laravel project is easy. Just use the command listed, and everything should work. It worked just fine for me.Finding and installing new packages
You can search for new packages on Packagist.org. The number of downloads and the number of stars are both good indicators of good packages. Just add the package you want to the composer.json file, run composer install to store the versions of the files you need. When you want to update your packages, test them in development first. And run run composer update.This section didn't make a lot of sense. I think the author could have been more clear in his intentions. He states that you run composer update to generate the composer.lock file, but then he says to be careful running this command as it will update the packages.
Links:
- https://packagist.org/
Additional advice
- commit compose.lock file file to version control
- exclude the contents of vendor/ directory. This should already be done in your .gitignore file
- do not edit the files in vendor/ directory, they will just be overwritten the next time you run composer install
- There are two switches you can use with composer --prefer-source and --prefer-dist. The --prefer-dist prefers stable releases and will try to not download the entire git history.
- composer's diagnose command and verbose flags can you help you find common problems with your packages.
Comments
Post a Comment