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) 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 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]
could 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/
