Composer installation and installation of the Laravel frame

Source: Internet
Author: User

Laravel claims to be one of the best PHP frameworks in the world, none of which are described below for its installation

Laravel Learning Exchange QQ Group: 293798134

Installation of composer:

PHP has a lot of developers and is absolutely dominant in the Web development world.
In the course of the 20 's development, countless developers have developed countless library classes.
But what do you do when you want to use a library?
For example: Phpmailer, a mail-sending library, we tend to do this:
1. Open the search engine and search for Phpmailer.
2. Download the source code from the Phpmailer website or the unknown site.
3. Unzip and put it in your project, and look at the manual call.
4. If phpmailer requires an SMTP class to function properly, continue downloading from the beginning.
As above, we can see that PHP developers, although many, the class library, but there are several problems.
1. There is no unified resource warehouse, looking everywhere.
2. There is no unified installation method. Rar,zip,tar all kinds of bags. After downloading, I have to tidy up.
3. Encounter the dependencies of the library, you have to download the solution.
Can be seen, PHP, although many libraries, but are scattered in all corners of the internet, not a system, and there is no unified norms.
Java has maven, Python has pip, node. JS has NPM, front end has bower
Since the composer, these libraries have been organized.

First Step installation method: Use the offline package installation (reason you understand)

We install composer need certain requirements, first we come to the storage Php.exe directory, the need to open the extension;
PHP version requires:>=5.5.9;
. OpenSSL extension
. PDO extension
. mbstring extension
If the above conditions are not met, please modify the php.ini configuration or recompile the ph offline package:

Baidu Network disk: HTTP://PAN.BAIDU.COM/S/1C1UAIHQ, Password: 3zuc

After downloading, get:

Place the two files in the same sibling directory that holds the Php.exe file:

Configure the environment variable, copy the path that holds php.exe to path, do not overwrite the path, and add it later

OK, run the command under the Cmd.exe window: composer-v

If the following interface appears, you have successfully installed composer

Because composer's software warehouse location is abroad, so we modify the domestic mirror, improve the speed,

Under the Cmd.exe window, enter the following command:

Composer Config-g Repositories.packagist composer https://packagist.phpcomposer.com

Step Two: preliminary composer

Let's install the next Smarty module:

First create your project, such as I create a blog this project

We came to https://packagist.org/(if not on the URL of the students should know what the reason, please carry a knife) search Smarty as follows:

Click to see Smarty version information, here we choose 3.1.30 version

Create a new Composer.json file in the blog's Directory,
Write the following JSON-formatted code:

{"   require": {         "smarty/smarty": "3.1.30"}}

Run the following command in the Cmd.exe window:

OK, you have successfully installed Smarty.

and the blog will automatically create Verdor this directory, the directory has the following files:

We're installing the Phpmailer.

The same method gets Phpmailer/phpmailer (the previous one represents the company name, the latter represents the product), and the code is added in Composer.json as follows:

{"   require": {         "smarty/smarty": "3.1.30",
"Phpmailer/phpmailer": "5.2.16"
}}
Also run the following command under the Cmd.exe window:

If the display does not succeed, it will show the Composer.json newer, composer.lock older such error

The solution is to enter the following command in Cmd.exe:

OK, congratulations, installation Phpmailer successful

So if you don't phpmailer it:

Still enter in the Cmd.exe window:

OK, delete succeeded,

Composer Remove Phpmailer/phpmailer, no need to add version number.
After the uninstallation succeeds, the Composer.json automatically becomes:
{
"Require": {
"Smarty/smarty": "3.1.30"
}
}

We can also not configure the Composer.json file when installing, directly enter the command directly in the Cmd.exe window: composer require phpmailer/phpmailer=5.2.16

Accordingly, the Composer.json file will automatically become as follows:

Version description of the library:

Step Three: Composer create the project:

In the cmd window, enter the following command:

Because the laravel5.1 version of the official commitment to long-term maintenance updates, although there are the latest 5.3 version, but the framework learning is similar, in general, with laravel5.1 better, here we choose 5.1.13 version

See below the blog has the following documents, you have successfully started Laravel learning journey

Composer installation and installation of the Laravel frame

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.