A personal note summarizing the commands to start the Laravel project.
Create with the project name tasklist
using Version 6 series
$ composer create-project --prefer-dist laravel/laravel tasklist ^6.0
Use Docker to launch the mysql
container.
$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=mysql -d -p 3306:3306 mysql
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4ded8e15debd mysql "docker-entrypoint.s…" 6 days ago Up 6 days 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
Create a DB after connecting to the container using the CONTAINER ID
displayed in the process.
The mysql password is the value specified by the MYSQL_ROOT_PASSWORD
argument.
$ docker exec -it 4ded8e15debd86c73e637b0c612bf30f0cd9de0aec04b4c09a0f53a6fa16f35d bash
root@4ded8e15debd:/# mysql -u root -p -h 127.0.0.1
Enter password: mysql
mysql> CREATE DATABASE tasklist;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| tasklist |
+--------------------+
5 rows in set (0.03 sec)
Define the connection information in the .env
file under the project.
Change the connection information according to the individual environment.
$ cd tasklist
$ vim .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tasklist
DB_USERNAME=root
DB_PASSWORD=mysql
Check if the web application can connect to the DB normally. If the following is displayed, you are connected.
$ php artisan tinker
Psy Shell v0.10.4 (PHP 7.4.10 — cli) by Justin Hileman
>>> DB::reconnect();
=> Illuminate\Database\MySqlConnection {#3233}
Since the default is UTC, change it to ʻAsia / Tokyo`.
$ vim config/app.php
'timezone' => 'Asia/Tokyo',
Start the internal server.
The default view of welcome.blade.php
is displayed.
$ php artisan serve --host=127.0.0.1 --port=8080
To stop the container, execute the following command.
$ docker stop { CONTAINER ID }
Recommended Posts