Use docker for laravel development environment. By the way, we will introduce how to set up a local command for docker containers.

Source: Internet
Author: User
Tags composer install docker run
Use docker for laravel development environment. By the way, we will introduce how to use laravel to set up the docker container cost commands. Laravel is one of the most popular php development frameworks in 2015.

I have some similar introductions on the Internet, but I think I should write one myself.

Create a file and grant the executable permission. The objective is to run the coomposer image as a local command.
$ cat /usr/local/bin/composer
! /Bin/sh

Export PATH =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

Echo "Current working directory: '" $ (pwd )"'"

Docker run -- rm-v $ (pwd):/app-v ~ /. Ssh:/root/. ssh composer/composer $ @

$ Chmod + x/usr/local/bin/composer

Check whether the PATH of the environment variable contains/usr/local/bin.

Of course, you can also use the alias method

alias composer="docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer"
Create a composer. json requirement Template
$ cat composer.json{"require": {    "laravel/installer": ">=1.3.3"}}
Install the laravel environment
composer install

In fact, at this time, the/usr/local/bin/composer is run, and the composer/composer image is called in the script.

Create the first project
$ composer create-project --prefer-dist laravel/laravel blog...phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)Writing lock fileGenerating autoload files> Illuminate\Foundation\ComposerScripts::postUpdate> php artisan optimizeGenerating optimized class loader

The APP_KEY is automatically updated. If there is no update, you can manually update it.

$ cd blog$ php artisan key:generate
Start the php Server
$ cd blog/public$ php -S localhost:8000

Then you can see the initial laravel website.

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.