PHP (vii) RESTful framework-lumen-settings and ENV

Source: Internet
Author: User
PHP (7) RESTful framework-lumen-settings and ENV
PHP (7) RESTful framework-lumen-settings and ENV

1. Install Lumen
Install composer
http://coderexample.com/composer-easy-tutorial/

Composer'll downloading dependency library automatically, and it'll create a single autoloader.php and autoload all th e dependency to our project.

> Curl-ss Https://getcomposer.org/installer | Php

This method would download the composer executive file. Actually I use this before, but we can move a little further, we can directly copy the executive file to our PATH director Y.
> sudo mv composer.phar/usr/bin/composer

Verify Installation
> Composer--version
Composer version 1.0-dev (f1aa655e6113e0efa979b8b09d7951a762eaa04c) 2015-08-20 11:59:54

2. Create the Sample Project
There is a lot of great source from here https://packagist.org/

This command would create a sample REST PHP project for us.
> Composer Create-project laravel/lumen easyphprest

Go to that directory. This command would 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 the 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_connection=mysql
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 would create a file under database/migrations/

Something like Flywaydb.
Run the command to start the migration table operation
> PHP Artisan Migrate

Error Message:

[Pdoexception]
Could not find driver


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

The link of the source
Http://ar2.php.net/distributions/php-5.6.10.tar.gz

Http://ar2.php.net/distributions/php-5.6.11.tar.gz

Install Pear http://pear.php.net/manual/en/installation.getting.php

> wget Http://pear.php.net/go-pear.phar

> PHP Go-pear.phar

Try to install Pdo_mysql
> Pear Install Pdo_mysql

> pecl Install Pdo_mysql

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

Solution:
Manually install that
Http://stackoverflow.com/questions/384809/pdo-mysql-driver-on-mac

> 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 headers files here
> cp/usr/local/mysql/include/*.h./

> Make

Maybe, I need to reinstall my PHP with this PDO MYSQL enable.
Reinstall PHP
http://sillycat.iteye.com/blog/2223621

Fetch the latest PHP
> wget http://ar2.php.net/distributions/php-5.6.11.tar.gz

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 would show on the Squel Pro

References:
Slim Framework
http://www.slimframework.com/

Laravel-web Framework similar to Symfony2
http://www.golaravel.com/
Http://laravel-china.org/docs/4.2/introduction
http://www.golaravel.com/

Lumen-restful Framework Mini version of Laravel
http://lumen.laravel.com/
http://segmentfault.com/a/1190000002724037
http://lumen.laravel-china.org/
https://phphub.org/topics/701
Http://lumen.laravel-china.org/docs

X-debug
Https://wiki.eclipse.org/Debugging_using_XDebug

Https://github.com/nordsoftware/lumen-rest
http://coderexample.com/restful-api-in-lumen-a-laravel-micro-framework/
  • 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.