国产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/

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

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動的應(yīng)用程序,用于創(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)

將語義結(jié)構(gòu)應(yīng)用于html的文章,部分和旁邊 將語義結(jié)構(gòu)應(yīng)用于html的文章,部分和旁邊 Jul 05, 2025 am 02:03 AM

在HTML中合理使用語義化標簽?zāi)芴嵘撁娼Y(jié)構(gòu)清晰度、可訪問性和SEO效果。1.用于獨立內(nèi)容區(qū)塊,如博客文章或評論,需保持自包含性;2.用于歸類相關(guān)內(nèi)容,通常包含標題,適用于頁面不同模塊;3.用于與主內(nèi)容相關(guān)但非核心的輔助信息,如側(cè)邊欄推薦或作者簡介。實際開發(fā)中應(yīng)結(jié)合、等標簽,避免過度嵌套,保持結(jié)構(gòu)簡潔,并通過開發(fā)者工具驗證結(jié)構(gòu)合理性。

在MySQL列和查詢中處理零值 在MySQL列和查詢中處理零值 Jul 05, 2025 am 02:46 AM

處理MySQL中的NULL值需注意:1.設(shè)計表時關(guān)鍵字段設(shè)為NOTNULL,可選字段允許NULL;2.查詢判斷必須用ISNULL或ISNOTNULL,不能用=或!=;3.可用IFNULL或COALESCE函數(shù)替換顯示默認值;4.插入或更新時直接使用NULL值需謹慎,注意數(shù)據(jù)源和ORM框架處理方式。NULL表示未知值,不等于任何值,包括自身,因此查詢、統(tǒng)計、連接表時要特別小心,避免漏數(shù)據(jù)或邏輯錯誤。合理使用函數(shù)和約束可以有效減少因NULL帶來的干擾。

分析MySQL緩慢查詢?nèi)罩疽圆檎倚阅芷款i 分析MySQL緩慢查詢?nèi)罩疽圆檎倚阅芷款i Jul 04, 2025 am 02:46 AM

開啟MySQL慢查詢?nèi)罩静⒎治隹啥ㄎ恍阅軉栴}。 1.編輯配置文件或動態(tài)設(shè)置slow_query_log和long_query_time;2.日志包含Query_time、Lock_time、Rows_examined等關(guān)鍵字段,輔助判斷效率瓶頸;3.使用mysqldumpslow或pt-query-digest工具高效分析日志;4.優(yōu)化建議包括添加索引、避免SELECT*、拆分復(fù)雜查詢等。例如為user_id加索引能顯著減少掃描行數(shù),提升查詢效率。

使用mySQL中的mysqldump執(zhí)行邏輯備份 使用mySQL中的mysqldump執(zhí)行邏輯備份 Jul 06, 2025 am 02:55 AM

mysqldump是用于執(zhí)行MySQL數(shù)據(jù)庫邏輯備份的常用工具,它生成包含CREATE和INSERT語句的SQL文件以重建數(shù)據(jù)庫。1.它不備份原始文件,而是將數(shù)據(jù)庫結(jié)構(gòu)和內(nèi)容轉(zhuǎn)換為可移植的SQL命令;2.適用于小型數(shù)據(jù)庫或選擇性恢復(fù),不適合TB級數(shù)據(jù)快速恢復(fù);3.常用選項包括--single-transaction、--databases、--all-databases、--routines等;4.恢復(fù)時使用mysql命令導(dǎo)入,并可關(guān)閉外鍵檢查以提升速度;5.建議定期測試備份、使用壓縮、自動化調(diào)

在MySQL中以極限和偏移的限制結(jié)果 在MySQL中以極限和偏移的限制結(jié)果 Jul 05, 2025 am 02:41 AM

MySQL分頁常用LIMIT和OFFSET實現(xiàn),但大數(shù)據(jù)量下性能較差。1.LIMIT控制每頁數(shù)量,OFFSET控制起始位置,語法為LIMITNOFFSETM;2.性能問題源于OFFSET掃描過多記錄并丟棄,導(dǎo)致效率低;3.優(yōu)化建議包括使用游標分頁、索引加速、懶加載;4.游標分頁通過上一頁最后一條記錄的唯一值定位下一頁起點,避免OFFSET,適合“下一頁”操作,不適合隨機跳轉(zhuǎn)。

通過MySQL中的群組和有條款匯總數(shù)據(jù) 通過MySQL中的群組和有條款匯總數(shù)據(jù) Jul 05, 2025 am 02:42 AM

GROUPBY用于按字段分組數(shù)據(jù)并執(zhí)行聚合操作,HAVING用于過濾分組后的結(jié)果。例如,使用GROUPBYcustomer_id可計算每個客戶的總消費金額;配合HAVING可篩選出總消費超過1000的客戶。SELECT后的非聚合字段必須出現(xiàn)在GROUPBY中,HAVING可使用別名或原始表達式進行條件篩選。常見技巧包括統(tǒng)計每組數(shù)量、多字段分組、結(jié)合多個條件過濾。

管理MySQL中的交易和鎖定行為 管理MySQL中的交易和鎖定行為 Jul 04, 2025 am 02:24 AM

MySQL事務(wù)和鎖機制是并發(fā)控制和性能調(diào)優(yōu)的關(guān)鍵。1.使用事務(wù)時,務(wù)必顯式開啟并保持事務(wù)短小,避免長事務(wù)導(dǎo)致資源占用和undolog膨脹;2.加鎖操作包括共享鎖和排他鎖,SELECT...FORUPDATE加X鎖,SELECT...LOCKINSHAREMODE加S鎖,寫操作自動加鎖,應(yīng)使用索引減少鎖粒度;3.隔離級別默認為可重復(fù)讀,適用于大多數(shù)場景,修改需謹慎;4.死鎖排查可通過SHOWENGINEINNODBSTATUS命令分析最近一次死鎖詳情,優(yōu)化方式包括統(tǒng)一執(zhí)行順序、增加索引、引入隊列系

如何在PHP中牢固地處理文件上傳? 如何在PHP中牢固地處理文件上傳? Jul 08, 2025 am 02:37 AM

要安全處理PHP文件上傳需驗證來源與類型、控制文件名與路徑、設(shè)置服務(wù)器限制并二次處理媒體文件。1.驗證上傳來源通過token防止CSRF并通過finfo_file檢測真實MIME類型使用白名單控制;2.重命名文件為隨機字符串并根據(jù)檢測類型決定擴展名存儲至非Web目錄;3.PHP配置限制上傳大小及臨時目錄Nginx/Apache禁止訪問上傳目錄;4.GD庫重新保存圖片清除潛在惡意數(shù)據(jù)。

See all articles