Install laravel and composerlaravel from a composer Image

Source: Internet
Author: User
Tags autoload composer install

Install laravel and composerlaravel from a composer Image

The blogger has recently learned about Laravel's framework. For many new features of Laravel, it is best to check the documentation on the official website. Laravel is very well-developed and has many Chinese and English documents, it can solve your confusion well.

However, we will find that the first threshold for learning Laravel is to install the dependency management tool Composer. The second threshold for installing Composer is to scientifically access the Internet (easily hitting the wall) based on Chinese characteristics ). Therefore, we can find that there are two barriers before we start learning Laravel. For new users, it is estimated that they will soon give up. But as a person who is interested in hitting the ground, how can he give up learning new startup (installation) skills because of these two barriers? There are two ways to install composer in windows: one is a silly installation, and the other is a command line on the tall. Younger brother, I was too easy to learn. I failed to successfully install composer in the command line, and switched to the silly next-> finished mode. There are many installation tutorials on the Internet, so I will not talk about them here.


1. Install Laravel and create a blog Project


First, let's talk about the method of direct installation. to use this method, we must first use FQ (which is determined by our basic national conditions ). There are two installation methods:

① Global installation

Run the Laravel Installer command to create a new project: laravel new blog.

Why not use this method?


[Plain]View plain copy
  1. When creating a project, laravel/installer needs to download from the laravel website (outside China. The compressed package is slow and may be wall-mounted at any time. It is written to the installer tool and cannot be configured. problems cannot be solved during use.


② Directly use Composer to create a new project

Run the command: composer create-project -- prefer-dist laravel/laravel blog. It seems that the first solution is better. However, due to the existence of the wall, the global installation of Laravel Installer may not be successful.


2. Use a domestic image for Installation


There are also two installation methods.

① Modify the global configuration file of composer (recommended)

Open the command line window (windows User) or Console (Linux or Mac user) and execute the following command:


[Plain]View plain copy
  1. Composer config-g repo. packagist composer


Then enter the installation command:


[Plain]View plain copy
  1. Composer create-project -- prefer-dist laravel/laravel blog


This speed is faster. Wait a moment and it will be finished.

② Modify the composer. json configuration file of the current project

Open the command line window (windows User) or Console (Linux or Mac user), enter the root directory of your project (that is, the Directory of the composer. json file), and execute the following command:


[Plain]View plain copy
  1. Composer config repo. packagist composer


The above command will automatically add the image configuration information at the end of the composer. json file in the current project (you can also manually add it ):


"repositories": {    "packagist": {        "type": "composer",        "url": ""    }}


Take the composer. json configuration file of the laravel project as an example. Execute the preceding command as follows (note the last few lines ):


{    "name": "laravel/laravel",    "description": "The Laravel Framework.",    "keywords": ["framework", "laravel"],    "license": "MIT",    "type": "project",    "require": {        "php": ">=5.5.9",        "laravel/framework": "5.2.*"    },    "require-dev": {        "fzaninotto/faker": "~1.4",        "mockery/mockery": "0.9.*",        "phpunit/phpunit": "~4.0",        "symfony/css-selector": "2.8.*|3.0.*",        "symfony/dom-crawler": "2.8.*|3.0.*"    },    "autoload": {        "classmap": [            "database"        ],        "psr-4": {            "App\\": "app/"        }    },    "autoload-dev": {        "classmap": [            "tests/TestCase.php"        ]    },    "scripts": {        "post-root-package-install": [            "php -r \"copy('.env.example', '.env');\""        ],        "post-create-project-cmd": [            "php artisan key:generate"        ],        "post-install-cmd": [            "php artisan clear-compiled",            "php artisan optimize"        ],        "pre-update-cmd": [            "php artisan clear-compiled"        ],        "post-update-cmd": [            "php artisan optimize"        ]    },    "config": {        "preferred-install": "dist"    },    "repositories": {        "packagist": {            "type": "composer",            "url": ""        }    }}



OK, everything is done! Try composer install to experience the normal speed!

Related Article

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: 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.