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
Http://coderexample.com/composer-easy-tutorial/
Composer will downloading dependency library automatically, and it will create a single autoloader. php and autoload all the dependency into our project.
-Curl-sS https://getcomposer.org/installer | 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 https://packagist.org/
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_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 will create a file under database/migrations/
Something like flywayDB.
Run the command to start the migration table operation
> Php artisan migrate
Error Message:
[PDOException]
Cocould not find driver
Solution:
Uncomment out 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 header 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 will 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/