git checkout

git initします。
[vagrant@localhost app]$ git init
Initialized empty Git repository in /home/vagrant/local/app/.git/

[vagrant@localhost app]$ vi sample.txt
[vagrant@localhost app]$ cat sample.txt
Hello Git!

[vagrant@localhost app]$ git add sample.txt
[vagrant@localhost app]$ git commit -m “git checkout”
[master (root-commit) c4b426e] git checkout
Committer: vagrant
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config –global user.name “Your Name”
git config –global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit –amend –author=’Your Name

1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 sample.txt

git branchを作成する。
[vagrant@localhost app]$ git branch branch1
[vagrant@localhost app]$ git branch branch2
[vagrant@localhost app]$ git branch
branch1
branch2
* master

[vagrant@localhost app]$ git checkout branch1
Switched to branch ‘branch1’
[vagrant@localhost app]$ git branch
* branch1
branch2
master
なるほど、checkoutはbranchの切り替えです。

[vagrant@localhost app]$ git checkout branch2
Switched to branch ‘branch2’
[vagrant@localhost app]$ cat sample.txt
Hello Git!

なるほど、なるほど。
最近なるほどが異常に増えた。

Laravel Homestead

Homesteadの意味がわからん。

>公式サイトを読んだ限りでは、仮想マシン上に、ほんの数分で、OS、Nginx、PHP5.5、MySQL、Postgres、Redis、Memcached等のLaravelアプリケーションを開発するための環境を提供してくれるツールだと記述されています
なに、osも?ってことは、dockerっというより、isoまで!?すげーな、最近のフレームワークは。

Laravel strives to make the entire PHP development experience delightful, including your local development environment. Vagrant provides a simple, elegant way to manage and provision Virtual Machines.
あ、vagrantって書いてます。

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
あ、なんだ、vagrant boxのことじゃん。box引っ張て来て、vagrant initするだけです。しかし、homesteadという名称がわかりにくい。

Homestead runs on any Windows, Mac, or Linux system, and includes the Nginx web server, PHP 7.3, PHP 7.2, PHP 7.1, PHP 7.0, PHP 5.6, MySQL, PostgreSQL, Redis, Memcached, Node, and all of the other goodies you need to develop amazing Laravel applications.
なぜapacheでない?? Nginx好きだなー

Ubuntu 18.04
Git
PHP 7.3
PHP 7.2
PHP 7.1
PHP 7.0
PHP 5.6
Nginx
Apache (Optional)
MySQL
MariaDB (Optional)
Sqlite3
PostgreSQL
Composer
Node (With Yarn, Bower, Grunt, and Gulp)
Redis
Memcached
Beanstalkd
Mailhog
Neo4j (Optional)
MongoDB (Optional)
Elasticsearch (Optional)
ngrok
wp-cli
Zend Z-Ray
Go
Minio

centosではなく、ubuntuです。Goもはいってる! beanstalkd, mailhog, neo4j, ngrok, wp-cli, minioは初めて見る。

setup
Before launching your Homestead environment, you must install VirtualBox 5.2, VMWare, Parallels or Hyper-V as well as Vagrant. All of these software packages provide easy-to-use visual installers for all popular operating systems.
To use the VMware provider, you will need to purchase both VMware Fusion / Workstation and the VMware Vagrant plug-in. Though it is not free, VMware can provide faster shared folder performance out of the box.
To use the Parallels provider, you will need to install Parallels Vagrant plug-in. It is free of charge.
Because of Vagrant limitations, The Hyper-V provider ignores all networking settings.
vagrantのプラグインか。

Once VirtualBox / VMware and Vagrant have been installed, you should add the laravel/homestead box to your Vagrant installation using the following command in your terminal. It will take a few minutes to download the box, depending on your Internet connection speed:

You may install Homestead by cloning the repository. Consider cloning the repository into a Homestead folder within your “home” directory, as the Homestead box will serve as the host to all of your Laravel projects:

homestead、ありました。
https://github.com/laravel/homestead

Once you have cloned the Homestead repository, run the bash init.sh command from the Homestead directory to create the Homestead.yaml configuration file. The Homestead.yaml file will be placed in the Homestead directory:

おおおおお、git checkoutが出てきた。
なんかきりねーぞ

laravel app directory

The majority of your application is housed in the app directory. By default, this directory is namespaced under App and is autoloaded by Composer using the PSR-4 autoloading standard.

ん?PSR-4 autoloading standard?
classのautoloadingが書いてある。app配下はconsole, exceptions, http, providers, user.phpです。
https://www.php-fig.org/psr/psr-4/

The app directory contains a variety of additional directories such as Console, Http, and Providers. Think of the Console and Http directories as providing an API into the core of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are two ways of issuing commands to your application. The Console directory contains all of your Artisan commands, while the Http directory contains your controllers, middleware, and requests.
httpディレクトリか。確かにControllers, kernel, Middlewareのディレクトリがあります。

A variety of other directories will be generated inside the app directory as you use the make Artisan commands to generate classes. So, for example, the app/Jobs directory will not exist until you execute the make:job Artisan command to generate a job class.
appディレクトリはartisanコマンドで生成できる。

Introduction
The default Laravel application structure is intended to provide a great starting point for both large and small applications. Of course, you are free to organize your application however you like. Laravel imposes almost no restrictions on where any given class is located – as long as Composer can autoload the class.

Where Is The Models Directory?
When getting started with Laravel, many developers are confused by the lack of a models directory. However, the lack of such a directory is intentional. We find the word “models” ambiguous since it means many different things to many different people. Some developers refer to an application’s “model” as the totality of all of its business logic, while others refer to “models” as classes that interact with a relational database.

For this reason, we choose to place Eloquent models in the app directory by default, and allow the developer to place them somewhere else if they choose.

The Root Directory
The App Directory
The app directory, as you might expect, contains the core code of your application. We’ll explore this directory in more detail soon; however, almost all of the classes in your application will be in this directory.

The Bootstrap Directory
The bootstrap directory contains the app.php file which bootstraps the framework. This directory also houses a cache directory which contains framework generated files for performance optimization such as the route and services cache files.

The Config Directory
The config directory, as the name implies, contains all of your application’s configuration files. It’s a great idea to read through all of these files and familiarize yourself with all of the options available to you.

The Database Directory
The database directory contains your database migrations, model factories, and seeds. If you wish, you may also use this directory to hold an SQLite database.

The Public Directory
The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.

The Resources Directory
The resources directory contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.

The Routes Directory
The routes directory contains all of the route definitions for your application. By default, several route files are included with Laravel: web.php, api.php, console.php and channels.php.

The web.php file contains routes that the RouteServiceProvider places in the web middleware group, which provides session state, CSRF protection, and cookie encryption. If your application does not offer a stateless, RESTful API, all of your routes will most likely be defined in the web.php file.

The api.php file contains routes that the RouteServiceProvider places in the api middleware group, which provides rate limiting. These routes are intended to be stateless, so requests entering the application through these routes are intended to be authenticated via tokens and will not have access to session state.

The console.php file is where you may define all of your Closure based console commands. Each Closure is bound to a command instance allowing a simple approach to interacting with each command’s IO methods. Even though this file does not define HTTP routes, it defines console based entry points (routes) into your application.

The channels.php file is where you may register all of the event broadcasting channels that your application supports.

The Storage Directory
The storage directory contains your compiled Blade templates, file based sessions, file caches, and other files generated by the framework. This directory is segregated into app, framework, and logs directories. The app directory may be used to store any files generated by your application. The framework directory is used to store framework generated files and caches. Finally, the logs directory contains your application’s log files.

The storage/app/public directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible. You should create a symbolic link at public/storage which points to this directory. You may create the link using the php artisan storage:link command.

The Tests Directory
The tests directory contains your automated tests. An example PHPUnit is provided out of the box. Each test class should be suffixed with the word Test. You may run your tests using the phpunit or php vendor/bin/phpunit commands.

The Vendor Directory
The vendor directory contains your Composer dependencies.

The App Directory
The majority of your application is housed in the app directory. By default, this directory is namespaced under App and is autoloaded by Composer using the PSR-4 autoloading standard.

The app directory contains a variety of additional directories such as Console, Http, and Providers. Think of the Console and Http directories as providing an API into the core of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are two ways of issuing commands to your application. The Console directory contains all of your Artisan commands, while the Http directory contains your controllers, middleware, and requests.

A variety of other directories will be generated inside the app directory as you use the make Artisan commands to generate classes. So, for example, the app/Jobs directory will not exist until you execute the make:job Artisan command to generate a job class.

Tip!! Many of the classes in the app directory can be generated by Artisan via commands. To review the available commands, run the php artisan list make command in your terminal.

The Broadcasting Directory
The Broadcasting directory contains all of the broadcast channel classes for your application. These classes are generated using the make:channel command. This directory does not exist by default, but will be created for you when you create your first channel. To learn more about channels, check out the documentation on event broadcasting.
特に使用なしか。

The Console directory contains all of the custom Artisan commands for your application. These commands may be generated using the make:command command. This directory also houses your console kernel, which is where your custom Artisan commands are registered and your scheduled tasks are defined.
consoleはartisanのカスタムだそう。ほえ、色々考えて設計されてます。

The Exceptions Directory
The Exceptions directory contains your application’s exception handler and is also a good place to place any exceptions thrown by your application. If you would like to customize how your exceptions are logged or rendered, you should modify the Handler class in this directory.
デフォルトではHandler.phpが入っています。

The Http Directory
The Http directory contains your controllers, middleware, and form requests. Almost all of the logic to handle requests entering your application will be placed in this directory.
ロジックはほぼHttpディレクトリで制御している。主に編集するのはこの箇所。

The Jobs Directory
This directory does not exist by default, but will be created for you if you execute the make:job Artisan command. The Jobs directory houses the queueable jobs for your application. Jobs may be queued by your application or run synchronously within the current request lifecycle. Jobs that run synchronously during the current request are sometimes referred to as “commands” since they are an implementation of the command pattern.

The Listeners Directory
This directory does not exist by default, but will be created for you if you execute the event:generate or make:listener Artisan commands. The Listeners directory contains the classes that handle your events. Event listeners receive an event instance and perform logic in response to the event being fired. For example, a UserRegistered event might be handled by a SendWelcomeEmail listener
デフォルトでないディレクトリがたくさんあります。

The Mail Directory
This directory does not exist by default, but will be created for you if you execute the make:mail Artisan command. The Mail directory contains all of your classes that represent emails sent by your application. Mail objects allow you to encapsulate all of the logic of building an email in a single, simple class that may be sent using the Mail::send method.
やはりメール送信ができるようです。よくできているなー

The Notifications Directory
This directory does not exist by default, but will be created for you if you execute the make:notification Artisan command. The Notifications directory contains all of the “transactional” notifications that are sent by your application, such as simple notifications about events that happen within your application. Laravel’s notification features abstracts sending notifications over a variety of drivers such as email, Slack, SMS, or stored in a database.
AWSのSNSみたいなもんか。

The Policies Directory
This directory does not exist by default, but will be created for you if you execute the make:policy Artisan command. The Policies directory contains the authorization policy classes for your application. Policies are used to determine if a user can perform a given action against a resource. For more information, check out the authorization documentation.
authorizationは一番勉強しなければならない分野かも。

The Providers Directory
The Providers directory contains all of the service providers for your application. Service providers bootstrap your application by binding services in the service container, registering events, or performing any other tasks to prepare your application for incoming requests.

In a fresh Laravel application, this directory will already contain several providers. You are free to add your own providers to this directory as needed.

The Rules Directory
This directory does not exist by default, but will be created for you if you execute the make:rule Artisan command. The Rules directory contains the custom validation rule objects for your application. Rules are used to encapsulate complicated validation logic in a simple object. For more information, check out the validation documentation.
ルールも作れます。このあたりは、プログラマーの好みがあると思います。

Directory Structure

ほう、英語ではDirectory structureと表現するのか。

Introduction
Where Is The Models Directory?
When getting started with Laravel, many developers are confused by the lack of a models directory. However, the lack of such a directory is intentional. We find the word “models” ambiguous since it means many different things to many different people. Some developers refer to an application’s “model” as the totality of all of its business logic, while others refer to “models” as classes that interact with a relational database.

For this reason, we choose to place Eloquent models in the app directory by default, and allow the developer to place them somewhere else if they choose.

appディレクトリを見よ。user.phpがmodel, httpのcontrollerがコントローラーか。

The Root Directory
The app directory, as you might expect, contains the core code of your application. We’ll explore this directory in more detail soon; however, almost all of the classes in your application will be in this directory.
appディレクトリが基礎となる。

The Bootstrap Directory
The bootstrap directory contains the app.php file which bootstraps the framework. This directory also houses a cache directory which contains framework generated files for performance optimization such as the route and services cache files.
あ、ホントだ、app.phpとcacheフォルダがある。

The Config Directory
The config directory, as the name implies, contains all of your application’s configuration files. It’s a great idea to read through all of these files and familiarize yourself with all of the options available to you.
config file全部見ろ、って言ってるwwww
しょうがない、見るか。全部returnで始まるね。
あ、s3に対応している、すげー
メールも充実しているね。smtpって随分出てくるけど、smtpの機能持ってるってこと??
なんだこりゃ、document読むのが一番手っ取り早い!

The Database Directory
The database directory contains your database migrations, model factories, and seeds. If you wish, you may also use this directory to hold an SQLite database.
migrateすると、ここにファイルができるのかな。

The Public Directory
The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.
ここは、フロントのファイル群です。

The Resources Directory
The resources directory contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.
view, sass, jsを入れるといってる。viewは解るが、sassはフロントでなくここ? jsでpublicとresourcesの違いは??

The Routes Directory
The routes directory contains all of the route definitions for your application. By default, several route files are included with Laravel: web.php, api.php, console.php and channels.php.
たのフレームワークと被るな。

主に触るのはweb.phpか。

The Storage Directory
The storage directory contains your compiled Blade templates, file based sessions, file caches, and other files generated by the framework. This directory is segregated into app, framework, and logs directories. The app directory may be used to store any files generated by your application. The framework directory is used to store framework generated files and caches. Finally, the logs directory contains your application’s log files.

The Tests Directory
The tests directory contains your automated tests. An example PHPUnit is provided out of the box. Each test class should be suffixed with the word Test. You may run your tests using the phpunit or php vendor/bin/phpunit commands.

The Vendor Directory
The vendor directory contains your Composer dependencies.
眠くなってきた。

Accessing Configuration Values

You may easily access your configuration values using the global config helper function from anywhere in your application. The configuration values may be accessed using “dot” syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:

$value = config('app.timezone');

あーなるほど、configの値を持ってこれるのね。面白いなこれ。
To set configuration values at runtime, pass an array to the config helper:

config(['app.timezone' => 'America/Chicago']);

なるほど、なるほど。完全にドキュメントを先に学んだ方がいいね、これは。

Configuration Caching
To give your application a speed boost, you should cache all of your configuration files into a single file using the config:cache Artisan command. This will combine all of the configuration options for your application into a single file which will be loaded quickly by the framework.
config:cacheを使えと言ってます。

Maintenance Mode
When your application is in maintenance mode, a custom view will be displayed for all requests into your application. This makes it easy to “disable” your application while it is updating or when you are performing maintenance. A maintenance mode check is included in the default middleware stack for your application. If the application is in maintenance mode, a MaintenanceModeException will be thrown with a status code of 503.

php artisan down

実務的にはよく使います。これは、503.phpを表示させたい。

You may also provide message and retry options to the down command. The message value may be used to display or log a custom message, while the retry value will be set as the Retry-After HTTP header’s value:

php artisan down --message="Upgrading Database" --retry=60

Even while in maintenance mode, specific IP addresses or networks may be allowed to access the application using the command’s allow option:

php artisan down --allow=127.0.0.1 --allow=192.168.0.0/16

これすげーーーーー、こんなの出来るんだ。
To disable maintenance mode, use the up command:

php artisan up

Maintenance Mode & Queues
While your application is in maintenance mode, no queued jobs will be handled. The jobs will continue to be handled as normal once the application is out of maintenance mode.

Alternatives To Maintenance Mode
Since maintenance mode requires your application to have several seconds of downtime, consider alternatives like Envoyer to accomplish zero-downtime deployment with Laravel.
なるほどばっかだーーーーー

Laravel Configuration

Introduction
All of the configuration files for the Laravel framework are stored in the config directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

config fileに全て入っているのは先ほど見た通りです。

Environment Configuration
It is often helpful to have different configuration values based on the environment where the application is running. For example, you may wish to use a different cache driver locally than you do on your production server.
ローカルのキャッシュドライバーを使えと言ってます。

To make this a cinch, Laravel utilizes the DotEnv PHP library by Vance Lucas. In a fresh Laravel installation, the root directory of your application will contain a .env.example file. If you install Laravel via Composer, this file will automatically be renamed to .env. Otherwise, you should rename the file manually.
.envファイルは大事です。

app, db, redis, mailなどの記載があります。

Your .env file should not be committed to your application’s source control, since each developer / server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository, since any sensitive credentials would get exposed.
git hubには.envはpushするなって書いてます。レポジトリを見ましたが、上がっていません。

If you are developing with a team, you may wish to continue including a .env.example file with your application. By putting place-holder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application. You may also create a .env.testing file. This file will override the .env file when running PHPUnit tests or executing Artisan commands with the –env=testing option.
teamなら.env.exampleを使えと言ってます。デフォルトでは.envと内容が一緒です。

Retrieving Environment Configuration
コード入力入っていきます。

'debug' => env('APP_DEBUG', false),

The current application environment is determined via the APP_ENV variable from your .env file. You may access this value via the environment method on the App facade:

Hiding Environment Variables From Debug Pages
debugのblackリストを設定できる?

return [

    // ...

    'debug_blacklist' => [
        '_ENV' => [
            'APP_KEY',
            'DB_PASSWORD',
        ],

        '_SERVER' => [
            'APP_KEY',
            'DB_PASSWORD',
        ],

        '_POST' => [
            'password',
        ],
    ],
];

laravel Nginx

Nginx
If you are using Nginx, the following directive in your site configuration will direct all requests to the index.php front controller:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Of course, when using Homestead or Valet, pretty URLs will be automatically configured.

む、apacheとnginxだとroutingが違うということか。

まず、apacheのversion確認
[vagrant@localhost ~]$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Jun 19 2018 15:45:13

apacheのHP
https://httpd.apache.org/
Apache httpd 2.4.37 Released 2018-10-23
お、大分差がありますね。

apachectlでも確認できる。
[vagrant@localhost ~]$ apachectl -v
Server version: Apache/2.2.15 (Unix)
Server built: Jun 19 2018 15:45:13

バージョン2.2系は、2005年12月1日にリリースされ、後述する2.4系が発表されるまで主流だったバージョンであり、現在でも利用しているユーザーは少なくない

バージョン2.4系は、これまでのApacheと比べて、メモリ使用量を削減するためにシステムを改善したり、あらゆるMPMをモジュールとしてビルド可能にする新機能などを追加したりという変更を施された最新のバージョン

なるほど、2.4系が主流ってことのよう。

[vagrant@localhost ~]$ nginx -V
-bash: nginx: コマンドが見つかりません

nginx が入ってない。入れるか。

laravel Web Server Configuration

Pretty URLs
Apache
Laravel includes a public/.htaccess file that is used to provide URLs without the index.php front controller in the path. Before serving Laravel with Apache, be sure to enable the mod_rewrite module so the .htaccess file will be honored by the server.

.htaccessを見てみましょう

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

あれ、ナニコレ、要するに、laravelのroutingってrewriteEngineで301リダイレクトさせてるってこと!?
Handle Authorization Header、Redirect Trailing Slashes If Not A Folder…、Handle Front Controller…って書いてますね。

RewriteCondはRewriteRule を実行するための条件を定義するための記述
ってことは、 %{HTTP:Authorization}、%{REQUEST_FILENAME}、%{REQUEST_URI} この辺は条件か。
REQUEST_URI リクエストURI
REQUEST_FILENAME リクエストされたファイル名

あーーーーーーなるほど、ドキュメントはやべーわ。フレームワークの重要なこと、全部書かれてるっぽい。
なるほど、フレームワーク使う時は、ドキュメント全部読まないと駄目だわこりゃ。
うわーーーーーーー頭いてー

Laravel Configuration

All of the configuration files for the Laravel framework are stored in the config directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

configファイルは、app.php, auth.php, broadcasting.php, cache.php … などが入っています。
app.phpは.envやtime zoneなどでしたね。

Directory Permissions
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.
ん? storageもresources/viewsもpublicも、いずれも755では。。。

Additional Configuration
Laravel needs almost no other configuration out of the box. You are free to get started developing! However, you may wish to review the config/app.php file and its documentation. It contains several options such as timezone and locale that you may wish to change according to your application.
あ、やっぱりconfig/app.php はまず見ておいた方が良さそうです。

asia/tokyoに変えます。localeも’ja’に。

'timezone' => 'Asia/Tokyo',
'locale' => 'ja',

あれ、リンクっぽいのがあるぞ、試しに踏んでみよう。
https://readouble.com/laravel/5.7/en/cache.html#configuration
https://readouble.com/laravel/5.7/en/database.html#configuration
https://readouble.com/laravel/5.7/en/session.html#configuration

ぎゃあああああああああああああああああああああああああ
がっつりリンクあるやんけ。
みなけりゃ良かった。。

あれ、俺が見てるのって、instalationのドキュメントじゃん。
シンプルなのはinstalltionだけで、ドキュメントすげーいっぱいあるじゃん。これ全部読むの?
まじかーーー、週末までかかるな。。。