PHP(7)RESTful Framework - Lumen - Settings and Env

PHP(7)RESTfulFramework-Lumen-SettingsandEnv

1.Installlumen

Installcomposer

http://coderexample.com/composer-easy-tutorial/

composerwilldownloadingdependencylibraryautomatically,anditwillcreateasingleautoloader.phpandautoloadallthedependencyintoourproject.

>curl-sShttps://getcomposer.org/installer|php

Thismethodwilldownloadthecomposerexecutivefile.ActuallyIusethatbefore,butwecanmovealittlefurther,wecandirectlycopytheexecutivefiletoourPATHdirectory.

>sudomvcomposer.phar/usr/bin/composer

Verifyinstallation

>composer--version

Composerversion1.0-dev(f1aa655e6113e0efa979b8b09d7951a762eaa04c)2015-08-2011:59:54

2.CreatetheSampleProject

Thereisalotofgreatsourcefromherehttps://packagist.org/

ThiscommandwillcreateasampleRESTPHPprojectforus.

>composercreate-projectlaravel/lumeneasyphprest

Gointothatdirectory.Thiscommandwilltellusalotofusefulcommands.

>phpartisan

LaravelFrameworkversionLumen(5.1.3)(LaravelComponents5.1.*)

CommandtostarttheHTTPService

>phpartisanserve

Lumendevelopmentserverstartedonhttp://localhost:8000/

InstallandConfigureMYSQL

AfterdirectlyinstalldmzfileonMAC,Istartmysqlasfollow:

>sudo/usr/local/mysql/support-files/mysql.serverstart

Databaseconfigurationisinthisplace

>cat.env

DB_CONNECTION=mysql

DB_HOST=localhost

DB_PORT=3306

DB_DATABASE=easyphprest

DB_USERNAME=easyphprest

DB_PASSWORD=easyphprest

Uncommentstheconfiguration

>catbootstrap/app.php

Dotenv::load(__DIR__.'/../');

$app->withFacades();

$app->withEloquent();

CreatetheMigrationDatabase

>phpartisanmake:migrationcreate_books_table

CreatedMigration:2015_08_28_183001_create_books_table

Thiswillcreateafileunderdatabase/migrations/

SomethinglikeflywayDB.

Runthecommandtostartthemigrationtableoperation

>phpartisanmigrate

ErrorMessage:

[PDOException]

couldnotfinddriver

Solution:

uncommentoutthelineinphp.ini

extension=php_pdo_mysql.dll

Thelinkofthesource

http://ar2.php.net/distributions/php-5.6.10.tar.gz

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

Installpearhttp://pear.php.net/manual/en/installation.getting.php

>wgethttp://pear.php.net/go-pear.phar

>phpgo-pear.phar

Trytoinstallpdo_mysql

>pearinstallpdo_mysql

>peclinstallpdo_mysql

Exception:

configure:error:CannotfindMySQLheaderfilesunder

ERROR:`/private/tmp/pear/install/PDO_MYSQL/configure'failed

Solution:

Manuallyinstallthat

http://stackoverflow.com/questions/384809/pdo-mysql-driver-on-mac

>pecldownloadpdo_mysql

>tarzxvfPDO_MYSQL-1.0.2.tgz

>phpize

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

>make

FailException:

./php_pdo_mysql_int.h:25:10:fatalerror:'mysql.h'filenotfound

#include<mysql.h>

easilycopyallthemysqlheaderfileshere

>cp/usr/local/mysql/include/*.h./

>make

Maybe,IneedtoreinstallmyPHPwiththisPDOMYSQLenable.

ReinstallPHP

FetchthelatestPHP

>wgethttp://ar2.php.net/distributions/php-5.6.11.tar.gz

Unzipandinstallation

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

Afterinstallation,switchtothislatestversionofPHP.Itworks.

>phpartisanmigrate

Migrationtablecreatedsuccessfully.

Migrated:2015_08_28_183001_create_books_table

ThedatabasetablewillshowontheSquelPro

References:

SlimFramework

http://www.slimframework.com/

laravel-WebFrameworksimilartosymfony2

http://www.golaravel.com/

http://laravel-china.org/docs/4.2/introduction

http://www.golaravel.com/

lumen-RESTfulframeworkminiversionoflaravel

http://lumen.laravel.com/

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/

相关推荐