Laravel PHP Framework(1)Introduction and Installation
Check PHP is on my Local Machine
> php --version
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
I am following the document to do with Laravel 5.6
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
> composer --version
Composer version 1.6.5 2018-05-04 11:44:59
Download the installer
> composer global require "laravel/installer"
Make sure it is in the PATH
export PATH=/Users/hluo/.composer/vendor/bin:$PATH
Check the version
> laravel -V
Laravel Installer 2.0.1
List all the command
> laravel list
Laravel Installer 2.0.1
Usage:
command [options] [arguments]
Create a sample project to demo
> laravel new blogdemo
It will create a project with all dependencies in blogdemo directory.
You can find all PHP package from here
https://packagist.org/
Make sublime open current folder
> sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
> subl .
It is pretty easy, that is cool.
> php artisan -V
Laravel Framework 5.6.29
Set Up MySQL 5.7 On MAC
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Temp password for root t?%VFE>kH4(M
Once we download the mysql server, we can download the MySQL Workbench and MySQL Shell.
In the Workbench, we can start one MySQL instance and reset the root password as we needed.
Then I can use the username and password to login in that console.
> mysql -h localhost -u carl -p
Create the database we need
> create database sillycat;
Grant the permission
> GRANT ALL ON sillycat.* TO sillycat@localhost IDENTIFIED BY '12345678';
Then we can logon on that database easily
> mysql -u sillycat -h localhost -p12345678
Import the data into that database
> mysql -u sillycat -h localhost -p12345678 sillycat </Users/hluo/work/sillycat/docs/sillycat.sql
I got the latest nodeJS environment
> node --version && npm --version
v8.11.3
5.6.0
When I do
> composer install
I got the error message about PHP environment
Problem 1
- Installation request for fgrosse/phpasn1 2.0.1 -> satisfiable by fgrosse/phpasn1[2.0.1].
- fgrosse/phpasn1 2.0.1 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
Problem 2
- Installation request for laravel/horizon v1.2.3 -> satisfiable by laravel/horizon[v1.2.3].
- laravel/horizon v1.2.3 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
Upgrade my PHP
https://php-osx.liip.ch/
> curl -s http://php-osx.liip.ch/install.sh | bash -s 7.2
Add this to the PATH
export PATH=/usr/local/php5/bin:$PATH
> php --version
PHP 7.2.9 (cli) (built: Aug 21 2018 07:42:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
When I go to the directory, I saw the file /usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/gmp.so
Find the ini file
> php --ini
Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File: /usr/local/php5/lib/php.ini
> sudo vi /usr/local/php5/lib/php.ini
extension=gmp
Problem solved.
Set Up Redis on Local Machine
> wget http://download.redis.io/releases/redis-4.0.11.tar.gz
Unzip the file and go to that directory
> make
> make PREFIX=/Users/hluo/tool/redis-4.0.11 install
> sudo ln -s /Users/hluo/tool/redis-4.0.11 /opt/redis-4.0.11
> redis-cli --version
redis-cli 4.0.11
We can change the redis.conf file to enable all the IP and port
bind 0.0.0.0
Command to run the server
> redis-server
Or
> redis-server ./redis.conf
Verify it is running
> redis-cli -h localhost -p 6379 ping
PONG
References:
https://laravel.com/
https://stackoverflow.com/questions/26402472/open-a-folder-in-sublime-text-3-using-command-line
https://packagist.org/
https://laracasts.com/series/laravel-from-scratch-2017/episodes/2?autoplay=true
Check PHP is on my Local Machine
> php --version
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
I am following the document to do with Laravel 5.6
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
> composer --version
Composer version 1.6.5 2018-05-04 11:44:59
Download the installer
> composer global require "laravel/installer"
Make sure it is in the PATH
export PATH=/Users/hluo/.composer/vendor/bin:$PATH
Check the version
> laravel -V
Laravel Installer 2.0.1
List all the command
> laravel list
Laravel Installer 2.0.1
Usage:
command [options] [arguments]
Create a sample project to demo
> laravel new blogdemo
It will create a project with all dependencies in blogdemo directory.
You can find all PHP package from here
https://packagist.org/
Make sublime open current folder
> sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
> subl .
It is pretty easy, that is cool.
> php artisan -V
Laravel Framework 5.6.29
Set Up MySQL 5.7 On MAC
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Temp password for root t?%VFE>kH4(M
Once we download the mysql server, we can download the MySQL Workbench and MySQL Shell.
In the Workbench, we can start one MySQL instance and reset the root password as we needed.
Then I can use the username and password to login in that console.
> mysql -h localhost -u carl -p
Create the database we need
> create database sillycat;
Grant the permission
> GRANT ALL ON sillycat.* TO sillycat@localhost IDENTIFIED BY '12345678';
Then we can logon on that database easily
> mysql -u sillycat -h localhost -p12345678
Import the data into that database
> mysql -u sillycat -h localhost -p12345678 sillycat </Users/hluo/work/sillycat/docs/sillycat.sql
I got the latest nodeJS environment
> node --version && npm --version
v8.11.3
5.6.0
When I do
> composer install
I got the error message about PHP environment
Problem 1
- Installation request for fgrosse/phpasn1 2.0.1 -> satisfiable by fgrosse/phpasn1[2.0.1].
- fgrosse/phpasn1 2.0.1 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
Problem 2
- Installation request for laravel/horizon v1.2.3 -> satisfiable by laravel/horizon[v1.2.3].
- laravel/horizon v1.2.3 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
Upgrade my PHP
https://php-osx.liip.ch/
> curl -s http://php-osx.liip.ch/install.sh | bash -s 7.2
Add this to the PATH
export PATH=/usr/local/php5/bin:$PATH
> php --version
PHP 7.2.9 (cli) (built: Aug 21 2018 07:42:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
When I go to the directory, I saw the file /usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/gmp.so
Find the ini file
> php --ini
Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File: /usr/local/php5/lib/php.ini
> sudo vi /usr/local/php5/lib/php.ini
extension=gmp
Problem solved.
Set Up Redis on Local Machine
> wget http://download.redis.io/releases/redis-4.0.11.tar.gz
Unzip the file and go to that directory
> make
> make PREFIX=/Users/hluo/tool/redis-4.0.11 install
> sudo ln -s /Users/hluo/tool/redis-4.0.11 /opt/redis-4.0.11
> redis-cli --version
redis-cli 4.0.11
We can change the redis.conf file to enable all the IP and port
bind 0.0.0.0
Command to run the server
> redis-server
Or
> redis-server ./redis.conf
Verify it is running
> redis-cli -h localhost -p 6379 ping
PONG
References:
https://laravel.com/
https://stackoverflow.com/questions/26402472/open-a-folder-in-sublime-text-3-using-command-line
https://packagist.org/
https://laracasts.com/series/laravel-from-scratch-2017/episodes/2?autoplay=true