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

首頁(yè) 後端開(kāi)發(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)站聲明
本文內(nèi)容由網(wǎng)友自願(yuàn)投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請(qǐng)聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅(qū)動(dòng)的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線(xiàn)上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強(qiáng)大的PHP整合開(kāi)發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺(jué)化網(wǎng)頁(yè)開(kāi)發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)程式碼編輯軟體(SublimeText3)

熱門(mén)話(huà)題

PHP標(biāo)頭位置AJAX調(diào)用不起作用 PHP標(biāo)頭位置AJAX調(diào)用不起作用 Jul 10, 2025 pm 01:46 PM

AJAX請(qǐng)求中header('Location:...')無(wú)效的原因是瀏覽器不會(huì)自動(dòng)執(zhí)行頁(yè)面跳轉(zhuǎn)。因?yàn)樵贏JAX請(qǐng)求中,服務(wù)器返回的302狀態(tài)碼和Location頭信息會(huì)被作為響應(yīng)數(shù)據(jù)處理,而不是觸發(fā)跳轉(zhuǎn)行為。解決方法有:1.在PHP中返回JSON數(shù)據(jù)包含跳轉(zhuǎn)URL;2.在前端AJAX回調(diào)中檢查redirect字段並用window.location.href手動(dòng)跳轉(zhuǎn);3.確保PHP輸出僅為JSON避免解析失?。?.處理跨域問(wèn)題需設(shè)置合適的CORS頭;5.防止緩存干擾可加時(shí)間戳或設(shè)置cache:f

PHP找到了最後一次發(fā)生的位置 PHP找到了最後一次發(fā)生的位置 Jul 09, 2025 am 02:49 AM

在PHP中查找子字符串最後一次出現(xiàn)的位置,最直接的方法是使用strrpos()函數(shù)。 1.使用strrpos()函數(shù)可直接獲取子字符串在主字符串中最後一次出現(xiàn)的起始位置索引,若未找到則返回false,語(yǔ)法為strrpos($haystack,$needle,$offset=0)。 2.若需忽略大小寫(xiě),可使用strripos()函數(shù)實(shí)現(xiàn)不區(qū)分大小寫(xiě)的查找。 3.對(duì)於中文等多字節(jié)字符,應(yīng)使用mbstring擴(kuò)展中的mb_strrpos()函數(shù)以確保返回字符位置而非字節(jié)位置。 4.注意strrpos()返回f

發(fā)電機(jī)如何在PHP中工作? 發(fā)電機(jī)如何在PHP中工作? Jul 11, 2025 am 03:12 AM

AgeneratorinPHPisamemory-efficientwaytoiterateoverlargedatasetsbyyieldingvaluesoneatatimeinsteadofreturningthemallatonce.1.Generatorsusetheyieldkeywordtoproducevaluesondemand,reducingmemoryusage.2.Theyareusefulforhandlingbigloops,readinglargefiles,or

如何防止PHP中的會(huì)話(huà)劫持? 如何防止PHP中的會(huì)話(huà)劫持? Jul 11, 2025 am 03:15 AM

要防止PHP中的會(huì)話(huà)劫持,需採(cǎi)取以下措施:1.使用HTTPS加密傳輸並在php.ini中設(shè)置session.cookie_secure=1;2.設(shè)置安全Cookie屬性,包括httponly、secure和samesite;3.在用戶(hù)登錄或權(quán)限變更時(shí)調(diào)用session_regenerate_id(true)更換SessionID;4.限制Session生命週期,合理配置gc_maxlifetime並記錄用戶(hù)活動(dòng)時(shí)間;5.禁止將SessionID暴露在URL中,設(shè)置session.use_only

如何用urlencode在PHP中編碼字符串 如何用urlencode在PHP中編碼字符串 Jul 11, 2025 am 03:22 AM

urlencode()函數(shù)用於將字符串編碼為URL安全格式,其中非字母數(shù)字字符(除-、_和.外)會(huì)被替換為百分號(hào)後跟兩位十六進(jìn)制數(shù)的形式。例如,空格轉(zhuǎn)為 號(hào),感嘆號(hào)轉(zhuǎn)為!,而中文字符則轉(zhuǎn)換為其UTF-8編碼形式。使用時(shí)應(yīng)僅對(duì)參數(shù)值進(jìn)行編碼,而非整個(gè)URL,以避免破壞URL結(jié)構(gòu)。對(duì)於URL的其他部分如路徑段,應(yīng)使用rawurlencode()函數(shù),其將空格轉(zhuǎn)為 。處理數(shù)組參數(shù)時(shí)可使用http_build_query()自動(dòng)編碼,或手動(dòng)對(duì)每個(gè)值調(diào)用urlencode()以確保安全傳輸數(shù)據(jù)。正

php獲得字符串的第一個(gè)N字符 php獲得字符串的第一個(gè)N字符 Jul 11, 2025 am 03:17 AM

在PHP中取字符串前N個(gè)字符可用substr()或mb_substr(),具體步驟如下:1.使用substr($string,0,N)截取前N個(gè)字符,適用於ASCII字符且簡(jiǎn)單高效;2.處理多字節(jié)字符(如中文)時(shí)應(yīng)使用mb_substr($string,0,N,'UTF-8'),並確保啟用mbstring擴(kuò)展;3.若字符串含HTML或空白字符,應(yīng)先用strip_tags()去除標(biāo)籤、trim()清理空格,再截取以保證結(jié)果乾淨(jìng)。

如何通過(guò)php中的索引訪(fǎng)問(wèn)字符串中的字符 如何通過(guò)php中的索引訪(fǎng)問(wèn)字符串中的字符 Jul 12, 2025 am 03:15 AM

在PHP中獲取字符串特定索引字符可用方括號(hào)或花括號(hào),但推薦方括號(hào);索引從0開(kāi)始,超出範(fàn)圍訪(fǎng)問(wèn)返回空值,不可賦值;處理多字節(jié)字符需用mb_substr。例如:$str="hello";echo$str[0];輸出h;而中文等字符需用mb_substr($str,1,1)獲取正確結(jié)果;實(shí)際應(yīng)用中循環(huán)訪(fǎng)問(wèn)前應(yīng)檢查字符串長(zhǎng)度,動(dòng)態(tài)字符串需驗(yàn)證有效性,多語(yǔ)言項(xiàng)目建議統(tǒng)一使用多字節(jié)安全函數(shù)。

優(yōu)化MySQL中的複雜加入操作 優(yōu)化MySQL中的複雜加入操作 Jul 09, 2025 am 01:26 AM

TooptimizecomplexJOINoperationsinMySQL,followfourkeysteps:1)EnsureproperindexingonbothsidesofJOINcolumns,especiallyusingcompositeindexesformulti-columnjoinsandavoidinglargeVARCHARindexes;2)ReducedataearlybyfilteringwithWHEREclausesandlimitingselected

See all articles