亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

首頁 后端開發(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ā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Clothoff.io

Clothoff.io

AI脫衣機(jī)

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集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

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

SublimeText3 Mac版

SublimeText3 Mac版

神級代碼編輯軟件(SublimeText3)

超越燈堆:PHP在現(xiàn)代企業(yè)體系結(jié)構(gòu)中的作用 超越燈堆:PHP在現(xiàn)代企業(yè)體系結(jié)構(gòu)中的作用 Jul 27, 2025 am 04:31 AM

PHPisstillrelevantinmodernenterpriseenvironments.1.ModernPHP(7.xand8.x)offersperformancegains,stricttyping,JITcompilation,andmodernsyntax,makingitsuitableforlarge-scaleapplications.2.PHPintegrateseffectivelyinhybridarchitectures,servingasanAPIgateway

PHP中的對象關(guān)聯(lián)映射(ORM)性能調(diào)整 PHP中的對象關(guān)聯(lián)映射(ORM)性能調(diào)整 Jul 29, 2025 am 05:00 AM

避免N 1查詢問題,通過提前加載關(guān)聯(lián)數(shù)據(jù)來減少數(shù)據(jù)庫查詢次數(shù);2.僅選擇所需字段,避免加載完整實(shí)體以節(jié)省內(nèi)存和帶寬;3.合理使用緩存策略,如Doctrine的二級緩存或Redis緩存高頻查詢結(jié)果;4.優(yōu)化實(shí)體生命周期,定期調(diào)用clear()釋放內(nèi)存以防止內(nèi)存溢出;5.確保數(shù)據(jù)庫索引存在并分析生成的SQL語句以避免低效查詢;6.在無需跟蹤變更的場景下禁用自動變更跟蹤,改用數(shù)組或輕量模式提升性能。正確使用ORM需結(jié)合SQL監(jiān)控、緩存、批量處理和適當(dāng)優(yōu)化,在保持開發(fā)效率的同時(shí)確保應(yīng)用性能。

為PHP創(chuàng)建準(zhǔn)備生產(chǎn)的Docker環(huán)境 為PHP創(chuàng)建準(zhǔn)備生產(chǎn)的Docker環(huán)境 Jul 27, 2025 am 04:32 AM

使用正確的PHP基礎(chǔ)鏡像并配置安全、性能優(yōu)化的Docker環(huán)境是實(shí)現(xiàn)生產(chǎn)就緒的關(guān)鍵。1.選用php:8.3-fpm-alpine作為基礎(chǔ)鏡像以減少攻擊面并提升性能;2.通過自定義php.ini禁用危險(xiǎn)函數(shù)、關(guān)閉錯(cuò)誤顯示并啟用Opcache及JIT以增強(qiáng)安全與性能;3.使用Nginx作為反向代理,限制訪問敏感文件并正確轉(zhuǎn)發(fā)PHP請求至PHP-FPM;4.采用多階段構(gòu)建優(yōu)化鏡像,移除開發(fā)依賴,設(shè)置非root用戶運(yùn)行容器;5.可選Supervisord管理多個(gè)進(jìn)程如cron;6.部署前驗(yàn)證無敏感信息泄

用PHP和RabbitMQ建造彈性微服務(wù) 用PHP和RabbitMQ建造彈性微服務(wù) Jul 27, 2025 am 04:32 AM

要構(gòu)建彈性的PHP微服務(wù),需使用RabbitMQ實(shí)現(xiàn)異步通信,1.通過消息隊(duì)列解耦服務(wù),避免級聯(lián)故障;2.配置持久化隊(duì)列、持久化消息、發(fā)布確認(rèn)和手動ACK以確保可靠性;3.使用指數(shù)退避重試、TTL和死信隊(duì)列安全處理失敗;4.通過supervisord等工具守護(hù)消費(fèi)者進(jìn)程并啟用心跳機(jī)制保障服務(wù)健康;最終實(shí)現(xiàn)系統(tǒng)在故障中持續(xù)運(yùn)作的能力。

python run shell命令示例 python run shell命令示例 Jul 26, 2025 am 07:50 AM

使用subprocess.run()可安全執(zhí)行shell命令并捕獲輸出,推薦以列表傳參避免注入風(fēng)險(xiǎn);2.需要shell特性時(shí)可設(shè)shell=True,但需警惕命令注入;3.使用subprocess.Popen可實(shí)現(xiàn)實(shí)時(shí)輸出處理;4.設(shè)置check=True可在命令失敗時(shí)拋出異常;5.簡單場景可直接鏈?zhǔn)秸{(diào)用獲取輸出;日常應(yīng)優(yōu)先使用subprocess.run(),避免使用os.system()或已棄用模塊,以上方法覆蓋了Python中執(zhí)行shell命令的核心用法。

在PHP中構(gòu)建不變的物體,并具有可讀的屬性 在PHP中構(gòu)建不變的物體,并具有可讀的屬性 Jul 30, 2025 am 05:40 AM

ReadonlypropertiesinPHP8.2canonlybeassignedonceintheconstructororatdeclarationandcannotbemodifiedafterward,enforcingimmutabilityatthelanguagelevel.2.Toachievedeepimmutability,wrapmutabletypeslikearraysinArrayObjectorusecustomimmutablecollectionssucha

深入了解PHP的內(nèi)部垃圾收集機(jī)制 深入了解PHP的內(nèi)部垃圾收集機(jī)制 Jul 28, 2025 am 04:44 AM

PHP的垃圾回收機(jī)制基于引用計(jì)數(shù),但循環(huán)引用需靠周期性運(yùn)行的循環(huán)垃圾回收器處理;1.引用計(jì)數(shù)在變量無引用時(shí)立即釋放內(nèi)存;2.循環(huán)引用導(dǎo)致內(nèi)存無法自動釋放,需依賴GC檢測并清理;3.GC在“可能根”zval達(dá)閾值或手動調(diào)用gc_collect_cycles()時(shí)觸發(fā);4.長期運(yùn)行的PHP應(yīng)用應(yīng)監(jiān)控gc_status()、適時(shí)調(diào)用gc_collect_cycles()以避免內(nèi)存泄漏;5.最佳實(shí)踐包括避免循環(huán)引用、使用gc_disable()優(yōu)化性能關(guān)鍵區(qū)及通過ORM的clear()方法解引用對象,最

無服務(wù)器革命:使用BREF部署可擴(kuò)展的PHP應(yīng)用程序 無服務(wù)器革命:使用BREF部署可擴(kuò)展的PHP應(yīng)用程序 Jul 28, 2025 am 04:39 AM

Bref使PHP開發(fā)者能無需管理服務(wù)器即可構(gòu)建可擴(kuò)展、成本高效的應(yīng)用。1.Bref通過提供優(yōu)化的PHP運(yùn)行時(shí)層,將PHP帶入AWSLambda,支持PHP8.3等版本,并與Laravel、Symfony等框架無縫集成;2.部署步驟包括:使用Composer安裝Bref,配置serverless.yml定義函數(shù)和事件,如HTTP端點(diǎn)和Artisan命令;3.執(zhí)行serverlessdeploy命令即可完成部署,自動配置APIGateway并生成訪問URL;4.針對Lambda限制,Bref提供解決

See all articles