国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 后端開發(fā) php教程 PHP(七)RESTful Framework - Lumen - Settings and Env

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

Jun 13, 2016 pm 12:24 PM
create gt mysql php with

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/

本站聲明
本文內容由網(wǎng)友自發(fā)貢獻,版權歸原作者所有,本站不承擔相應法律責任。如您發(fā)現(xiàn)有涉嫌抄襲侵權的內容,請聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅動的應用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機

Video Face Swap

Video Face Swap

使用我們完全免費的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強大的PHP集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級代碼編輯軟件(SublimeText3)

在C中使用std :: Chrono 在C中使用std :: Chrono Jul 15, 2025 am 01:30 AM

std::chrono在C 中用于處理時間,包括獲取當前時間、測量執(zhí)行時間、操作時間點與持續(xù)時間及格式化解析時間。1.獲取當前時間使用std::chrono::system_clock::now(),可轉換為可讀字符串但系統(tǒng)時鐘可能不單調;2.測量執(zhí)行時間應使用std::chrono::steady_clock以確保單調性,并通過duration_cast轉換為毫秒、秒等單位;3.時間點(time_point)和持續(xù)時間(duration)可相互操作,但需注意單位兼容性和時鐘紀元(epoch)

PHP如何處理環(huán)境變量? PHP如何處理環(huán)境變量? Jul 14, 2025 am 03:01 AM

toAccessenvironmentVariablesInphp,useGetenv()或$ _envsuperglobal.1.getEnv('var_name')retievesSpecificvariable.2。$ _ en v ['var_name'] accessesvariablesifvariables_orderInphp.iniincludes“ e” .setVariablesViaCliWithvar = vualitephpscript.php,inapach

mysql公共表表達式(CTE)示例 mysql公共表表達式(CTE)示例 Jul 14, 2025 am 02:28 AM

CTE是MySQL中用于簡化復雜查詢的臨時結果集。它在當前查詢中可多次引用,提升代碼可讀性和維護性。例如,在orders表中查找每個用戶的最新訂單時,可通過CTE先獲取每個用戶的最新訂單日期,再與原表關聯(lián)獲取完整記錄。相比子查詢,CTE結構更清晰,邏輯更易調試。使用技巧包括明確別名、串聯(lián)多個CTE以及利用遞歸CTE處理樹形數(shù)據(jù)。掌握CTE能使SQL更優(yōu)雅高效。

php準備的語句與條款 php準備的語句與條款 Jul 14, 2025 am 02:56 AM

使用PHP預處理語句執(zhí)行帶有IN子句的查詢時,1.需根據(jù)數(shù)組長度動態(tài)生成占位符;2.使用PDO時可直接傳入數(shù)組,用array_values確保索引連續(xù);3.使用mysqli時需構造類型字符串并綁定參數(shù),注意展開數(shù)組的方式及版本兼容性;4.避免拼接SQL、處理空數(shù)組和確保數(shù)據(jù)類型匹配。具體做法是:先用implode與array_fill生成占位符,再依擴展特性綁定參數(shù),從而安全執(zhí)行IN查詢。

為什么我們評論:PHP指南 為什么我們評論:PHP指南 Jul 15, 2025 am 02:48 AM

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

如何避免PHP中未定義的索引錯誤 如何避免PHP中未定義的索引錯誤 Jul 14, 2025 am 02:51 AM

避免“undefinedindex”錯誤的關鍵方法有三:首先,使用isset()檢查數(shù)組鍵是否存在并確保值不為null,適用于大多數(shù)常規(guī)場景;其次,使用array_key_exists()僅判斷鍵是否存在,適用于需要區(qū)分鍵不存在和值為null的情況;最后,使用空合并運算符??(PHP7 )簡潔地設置默認值,推薦用于現(xiàn)代PHP項目,同時注意表單字段名拼寫、謹慎使用extract()及遍歷前檢查數(shù)組非空以進一步規(guī)避風險。

為MySQL表中的列選擇適當?shù)臄?shù)據(jù)類型 為MySQL表中的列選擇適當?shù)臄?shù)據(jù)類型 Jul 15, 2025 am 02:25 AM

insetTingUpmysqltables,選擇theStherightDatatatPesisionCrucialForeffifeffifeffifeffificeFifeffifeFrifeFifeScalible

PHP標頭重定向不起作用 PHP標頭重定向不起作用 Jul 14, 2025 am 01:59 AM

header函數(shù)跳轉失敗原因及解決方法:1.header前已有輸出,需檢查并移除所有前置輸出或使用ob_start()緩沖;2.未加exit導致后續(xù)代碼干擾,應在跳轉后立即添加exit或die;3.路徑錯誤應使用絕對路徑或動態(tài)拼接確保正確;4.服務器配置或緩存干擾可嘗試清除緩存或更換環(huán)境測試。

See all articles