PHP (7) RESTfulFramework-Lumen-SettingsandEnv

Source: Internet
Author: User
PHP (7) RESTfulFramework-Lumen-SettingsandEnvPHP (7) RESTfulFramework-Lumen-SettingsandEnv1.InstalllumenInstallcomposercoderexample.comcomposer-easy-tuto PHP (7) RESTful Framework-Lumen-Settings and Env
PHP (7) RESTful Framework-Lumen-Settings and Env

1. Install lumen
Install composer

Composer will downloading dependency library automatically, and it will create a single autoloader. php and autoload all the dependency into our project.

-Curl-sS | php

This method will download the composer executive file. Actually I use that before, but we can move a little further, we can directly copy the executive file to our PATH directory.
> Sudo mv composer. phar/usr/bin/composer

Verify installation
> Composer -- version
Composer version 1.0-dev (f1aa655e6113e0efa979b8b09d7951a762eaa04c) 11:59:54

2. Create the Sample Project
There is a lot of great source from here

This command will create a sample rest php project for us.
> Composer create-project laravel/lumen easyphprest

Go into that directory. This command will tell us a lot of useful commands.
> Php artisan
Laravel Framework version Lumen (5.1.3) (Laravel Components 5. 1 .*)

Command to start the HTTP Service
> Php artisan serve
Lumen development server started on http: // localhost: 8000/

Install and Configure MYSQL
After directly install dmz file on MAC, I start mysql as follow:
> Sudo/usr/local/mysql/support-files/mysql. server start

Database configuration is in this place
> Cat. env
DB_HOST = localhost
DB Port = 3306
DB_DATABASE = easyphprest
DB_USERNAME = easyphprest
DB_PASSWORD = easyphprest

Uncomments the configuration
> Cat bootstrap/app. php
Dotenv: load (_ DIR __.'/../');
$ App-> withFacades ();
$ App-> withEloquent ();

Create the Migration Database
> Php artisan make: migration create_books_table
Created Migration: 2015_08_28_183001_create_books_table

This will create a file under database/migrations/

Something like flywayDB.
Run the command to start the migration table operation
> Php artisan migrate

Error Message:

Cocould not find driver

Uncomment out the line in php. ini
Extension = php_pdo_mysql.dll

The link of the source


Install pear

> Wget

> Php go-pear.phar

Try to install pdo_mysql
> Pear install pdo_mysql

> Pecl install pdo_mysql

Configure: error: Cannot find MySQL header files under
ERROR: '/private/tmp/pear/install/PDO_MYSQL/configure' failed

Manually install that

> Pecl download pdo_mysql

> Tar zxvf PDO_MYSQL-1.0.2.tgz

> Phpize

>./Configure -- with-pdo-mysql =/usr/local/mysql

> Make

Fail Exception:
./Php_pdo_mysql_int.h: 25: 10: fatal error: 'MySQL. h' file not found
# Include

Easily copy all the mysql header files here
> Cp/usr/local/mysql/include/*. h ./

> Make

Maybe, I need to reinstall my PHP with this PDO MYSQL enable.
Reinstall PHP

Fetch the latest PHP
> Wget

Unzip and installation
>. /Configure -- prefix =/Users/carl/tool/php-5.6.11 -- with-openssl -- with-iconv-dir =/usr/lib -- with-curl =/opt/local/include/ curl -- with-mysql -- enable-fpm -- with-zlib-dir -- with-freetype-dir -- enable-mbstring -- with-libxml-dir =/usr -- enable-soap -- enable -calendar -- with-mysqli -- with-pdo-mysql -- with-zlib

After installation, switch to this latest version of PHP. It works.
> Php artisan migrate
Migration table created successfully.
Migrated: 2015_08_28_183001_create_books_table

The database table will show on the Squel Pro

Slim Framework

Laravel-Web Framework similar to symfony2

Lumen-RESTful framework mini version of laravel



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.