Laravel5.7 트레이닝 1(환경 구축~HelloWorld)
8759 단어 PHP7도커LaraDocklaravel5.7
목적
목표
환경 구축
Laradock 가 편리하다고 들었기 때문에 그것 사용합니다.
전제
자신의 환경
Laradock 소개
기본적으로 공식 참조
# clone
[03:34:54] takai@MyMBP /Users/takai/laravel-training (0)
> git clone https://github.com/laradock/laradock.git
# Project directory
[03:47:17] takai@MyMBP /Users/takai/laravel-training (0)
> mkdir hello-world
[03:47:28] takai@MyMBP /Users/takai/laravel-training (0)
> ll
total 0
drwxr-xr-x 2 takai staff 64B 3 28 03:47 hello-world
drwxr-xr-x 77 takai staff 2.4K 3 28 03:46 laradock
[03:47:35] takai@MyMBP /Users/takai/laravel-training (0)
> cd laradock/
[03:48:05] takai@MyMBP /Users/takai/laravel-training/laradock (0)
> cp env-example .env
APP_CODE_PATH_HOST
를 방금 만든 프로젝트의 상대 경로로 편집 # Point to the path of your applications code on your host
APP_CODE_PATH_HOST=../hello-world/
/laradock/mysql/my.conf
# 末尾に追加
default_authentication_plugin= mysql_native_password
docker-compose up
에서 컨테이너 시작 (괜찮 았어) [04:00:48] takai@MyMBP /Users/takai/laravel-training/laradock (0)
> docker-compose up -d nginx mysql
[04:20:48] takai@MyMBP /Users/takai/laravel-training/laradock (1)
> docker-compose exec --user=laradock workspace bash
laradock@c46d12c67821:/var/www$
./hello-world/hello-world.php
<?php
print "HelloWorld!\n";
laradock@c46d12c67821:/var/www$ ls
hello-world.php
laradock@c46d12c67821:/var/www$ php hello-world.php
HelloWorld!
# あとで邪魔になるので消しとく
laradock@c46d12c67821:/var/www$ rm hello-world.php
HelloWorld
composer에서 Laravel 프로젝트 만들기
laradock@4a6645da762b:/var/www$ composer create-project --prefer-dist laravel/laravel=5.7.* ./
/hello-world/.env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret
laradock@4a6645da762b:/var/www$ php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table
/hello-world/routes/web.php
<?php
Route::get('/', function () {
return view('welcome');
});
// 追加
Route::get('/hello-world', function () {
return view('hello');
});
/hello-world/resources/views/hello.blade.php
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Nunito', sans-serif;
font-weight: 200;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 13px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
@if (Route::has('register'))
<a href="{{ route('register') }}">Register</a>
@endif
@endauth
</div>
@endif
<div class="content">
<div class="title m-b-md">
Hello Laravel Wolrd!
</div>
</div>
</div>
</body>
</html>
Reference
이 문제에 관하여(Laravel5.7 트레이닝 1(환경 구축~HelloWorld)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kiyoneet/items/410443b76dd913c5eafe텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)