การติดตั้ง Laravel 5.2 กับ Xampp บน Windows


https://laravel.com/docs/5.2

1. โหลดติดตั้ง Xampp ก็ติดตั้งไปตามปกติ อันที่เราติดตั้งนี่ เป็น Xampp V.7.0.4 ซึ่งมี PHP 7.0.4 พวก OpenSSL ที่ต้องเปิด เค้าก็เซ็ตมาหมดล่ะค่ะ ติดตั้งปกติเลย

Install Xampp V.7.0.4 normally. All requirements that Laravel requires are set. No need to do more, just intsall Xampp.

https://www.apachefriends.org/download.html


2. โหลดติดตั้ง Composer (Composer-Setup.exe) ตามปกติ ซึ่งมันจะมีคำบอกให้ทำ ดังนี้ (เดี๋ยวค่อยทำ)

Install Composer (Composer-Setup.exe) normally. After install, be careful the notice. (I will do it later)

https://getcomposer.org/download/



3. ใส่ PATH ต่อไปนี้ ใน Environment Variables (คลิกขวา My Computer/This PC > Advanced system settings > Advanced tab > Environment Variables > ใส่ต่อท้ายใน PATH ใน System variables อย่าลืมคั่นด้วย ;)

พาธที่จะใส่ ให้เปลี่ยน YOUR_USERNAME เป็นชื่อ user ในเครื่องตัวเอง

Add the following to the PATH Environment Variables (right click My Computer/This PC > Advanced system settings > Advanced tab > Environment Variables > add in the PATH in System variables divided by ;)

YOUR_USERNAME means your username in your computer

C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin

4. ทำตามที่รูปข้อ 2 ว่า คือ ปิดเปิด Command Prompt ขึ้นมาใหม่ Log off/on หรือ Restart Computer

Follow the steps in the picture above. Close the current Command Prompt and open a new one. Log off/on or restart computer.

5. เปิด Command Prompt แล้ว รันคำสั่ง

Open a Command Prompt. Run this.

composer global require "laravel/installer"

6. เปลี่ยน path directory ไปที่ folder ที่ต้องการ ในที่ เราจะเอา Project ต่างๆ ที่สร้างขึ้นใน folder ชื่อ laravel ใน htdocs

Change the path directory that you want to create a laravel project. In my case I want to create in c:/xampp/htdocs/laravel so I run.

cd c:/xampp/htdocs/laravel

7. รันคำสั่งต่อไปนี้ เพื่อสร้าง project เราลองใช้คำสั่ง laravel new myFirstLaravel แล้ว ไม่เวิร์คอ่ะ อันนี้ดีกว่า จะได้ folder C:\xampp\htdocs\laravel\myFirstLaravel

Run this to create a new project. My project names myFirstLaravel. I also try another commnad (laravel new myFirstLaravel) in official web site and found it won't work. After finishing, you will get you new project in C:\xampp\htdocs\laravel\myFirstLaravel

composer create-project --prefer-dist laravel/laravel myFirstLaravel

8. กด Start Apache และ MySQL ใน Xampp

Start Apache and MySQL (if any) service in Xampp.

9. เปิด browser ลองใส่ url http://localhost/laravel/myFirstLaravel/public/ ถ้าสำเร็จจะขึ้นหน้าจอ Laravel 5

Open browser, try URL http://localhost/laravel/myFirstLaravel/public/. It will result Laravel 5 screen.



Some time you will get this error likes this.
Warning: require(C:\xampp\htdocs\laravel\myFirstLaravel\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravel\myFirstLaravel\bootstrap\autoload.php on line 17

Fatal error: require(): Failed opening required 'C:\xampp\htdocs\laravel\myFirstLaravel\bootstrap/../vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\laravel\myFirstLaravel\bootstrap\autoload.php on line 17

I face this error. I don't know too much. It can't find the vendor path. I think you maybe forget to restart the command prompt after finishing the Composer installation or the command "laravel new myFirstLaravel" does not work. So just try to follow my steps above. It shoud work well.




Previous
Next Post »