make:auth 認証時のエラー処理

resources/lang/en/passwords.phpを変更する。

‘failed’ => ‘These credentials do not match our records.’,
‘throttle’ => ‘Too many login attempts. Please try again in :seconds seconds.’,

目算間違えた。。結構やらなきゃいけない量が大量にあるな。

make:auth後のルーティング

[vagrant@localhost demo]$ php artisan route:list
+——–+———-+————————+——————+————————————————————————+————–+
| Domain | Method | URI | Name | Action | Middleware |
+——–+———-+————————+——————+————————————————————————+————–+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | GET|HEAD | home | home | App\Http\Controllers\HomeController@index | web,auth |
| | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest |
| | POST | login | | App\Http\Controllers\Auth\LoginController@login | web,guest |
| | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web |
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest |
| | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest |
| | POST | password/reset | password.update | App\Http\Controllers\Auth\ResetPasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest |
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web,guest |
+——–+———-+————————+——————+————————————————————————+————–+

/home はログイン後の画面

routes/web.php

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

resources/views/authに以下のphpファイルが出来ている
– login.blade.php
– register.blade.php
– verify.blade.php
– passwords/email.blade.php
– passwords/reset.blade.php

また、views/layouts/app.blade.php もできている。

app/Http/controllers/Auth にcontrollerもできている。
ForgotPasswordController.php
LoginController.php
RegisterController.php
ResetPasswordController.php
VertificationController.php

database/migration
users_table.php, password_resets_table.php

LoginController、RegisterController、ResetPasswordControllerのリダイレクト先を変更する。デフォルトはhome

protected $redirectTo = '/';

laravelでログイン機能を作ろう

composerをインストールした後に、laravelを入れます。
そうですね、project nameはdemoあたりにしておきましょう。

$ php composer.phar create-project –prefer-dist laravel/laravel demo
Installing laravel/laravel (v5.7.0)

続いてDBをつくる
mysql> create database demo;

DBを設定していく
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=hoge
DB_USERNAME=hoge
DB_PASSWORD=hoge

[vagrant@localhost demo]$ php artisan make:auth
Authentication scaffolding generated successfully.

あれ? なんじゃこりゃ?
[vagrant@localhost demo]$ php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

[vagrant@localhost demo]$ php artisan serve –host=192.168.35.10 –port=8000
Laravel development server started:

mysql> use demo
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+—————-+
| Tables_in_demo |
+—————-+
| migrations |
| users |
+—————-+
2 rows in set (0.00 sec)

mysql> describe users;
+——————-+——————+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+——————-+——————+——+—–+———+—————-+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| email | varchar(255) | NO | | NULL | |
| email_verified_at | timestamp | YES | | NULL | |
| password | varchar(255) | NO | | NULL | |
| remember_token | varchar(100) | YES | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
+——————-+——————+——+—–+———+—————-+
8 rows in set (0.11 sec)

なんじゃこりゃーーーーーーーーーーーーーーーーーーーーーー??
えええ?
意味が分からん。。
認証機能ね。

/config/auth.php

password_reset tableがないな。。

php artisan serve –host 192.168.35.10 –port 8000

Too many arguments, expected arguments “command”.

ん?

[vagrant@localhost laravel]$ php artisan serve -host=192.168.35.10 -port=8000
Description:
Serve the application on the PHP development server

Usage:
serve [options]

Options:
–host[=HOST] The host address to serve the application on [default: “127.0.0.1”]
–port[=PORT] The port to serve the application on [default: 8000]
-h, –help Display this help message
-q, –quiet Do not output any message
-V, –version Display this application version
–ansi Force ANSI output
–no-ansi Disable ANSI output
-n, –no-interaction Do not ask any interactive question
–env[=ENV] The environment the command should run under
-v|vv|vvv, –verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

hostは –hostですな。

修正しました。
[vagrant@localhost laravel]$ php artisan serve –host=192.168.35.10 –port=8000

さて、まずやっていくのは
1. ログイン機能
2. テーブル作成

このあたりか。
ログインはいきなり実装するのは怖い。

rsync

rsync は、UNIXシステムにおいて、差分符号化を使ってデータ転送量を最小化し、遠隔地間のファイルやディレクトリの同期を行う

apache benchを使ってみよう

[vagrant@localhost app]$ ab -n 10 -c 10 http://www.hpscript.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.hpscript.com (be patient)…..done

Server Software: nginx
Server Hostname: www.hpscript.com
Server Port: 80

Document Path: /
Document Length: 0 bytes

Concurrency Level: 10
Time taken for tests: 3.639 seconds
Complete requests: 10
Failed requests: 2
(Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors: 0
Non-2xx responses: 10
Total transferred: 3040 bytes
HTML transferred: 1066 bytes
Requests per second: 2.75 [#/sec] (mean)
Time per request: 3638.692 [ms] (mean)
Time per request: 363.869 [ms] (mean, across all concurrent requests)
Transfer rate: 0.82 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 55 62 4.8 64 69
Processing: 732 2269 694.0 2483 2801
Waiting: 717 2256 690.2 2479 2787
Total: 787 2331 695.1 2538 2865

Percentage of the requests served within a certain time (ms)
50% 2538
66% 2754
75% 2792
80% 2855
90% 2865
95% 2865
98% 2865
99% 2865
100% 2865 (longest request)

以下が時間ですな。
Time per request: 3638.692 [ms] (mean)
Time per request: 363.869 [ms] (mean, across all concurrent requests)

これは結構使えるかも。

twilio

Twilioは音声通話、メッセージング(SMS/チャット)、ビデオなどの様々なコミュニケーション手段を、 アプリケーションやビジネスへ容易に組み込むことのできるクラウドAPIサービス

とりあえず、composerで入れてみます。

[vagrant@localhost app]$ php coposer.phar require twilio/sdk
Using version ^5.23 for twilio/sdk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
– Installing dg/rss-php (v1.2): Downloading (100%)
– Installing twilio/sdk (5.23.1): Downloading (100%)
Writing lock file
Generating autoload files

PHPUnit

品質の良いプロダクトコードを書くことができるようになる。

use PHPUnit\Framework\TestCase;

classs HogeTest extends TestCase
{
	public function testHoge()
	{
		$stack = [];
		$this->assertEquals(0, count($stack));
	}
}

単体テストとは?

単体テスト(ユニットテストと呼ばれることもあります)は、プログラムを構成する比較的小さな単位(ユニット)が個々の機能を正しく果たしているかどうかを検証するテスト

通常、関数やメソッドが単体テストの単位(ユニット)となります。 プログラムが全体として正しく動作しているかを検証する結合テストは、開発の比較的後の段階でQAチームなどによって行なわれることが多いのとは対照的に、単体テストは、コード作成時などの早い段階で開発者によって実施されることが多いのが特徴

コードの内容をよく理解している開発者によって、コード作成と同時か直後に(または、『テスト駆動型開発』Test Driven Development:TDD と呼ばれる開発手法ではコードの作成よりも前に)テストケースが作成されるため、妥当性の高いテストケースを資産として残すことができ、後の拡張開発や改修時にも再利用できる

/etc/zabbix/zabbix_server.conf

/etc/zabbix/zabbix_server.conf

編集していきます。

DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpassword
DBSocket=/var/lib/mysql/mysql.sock

mysql.sockって何? /var/lib/mysqlにmysqlで作成したdatabase一覧がありますね。

zabbix serverを起動

[vagrant@localhost zabbix]$ sudo service zabbix-server start
Starting Zabbix server: [ OK ]

うお!

あ、これやってなかった。
yum install -y zabbix-web zabbix-web-mysql zabbix-web-japanese

こうか?
[vagrant@localhost src]$ cd /usr/share/doc/zabbix-web-3.0.22
[vagrant@localhost zabbix-web-3.0.22]$ cp httpd24-example.conf /etc/httpd/conf.d/zabbix.conf
cp: cannot create regular file `/etc/httpd/conf.d/zabbix.conf’: 許可がありません
[vagrant@localhost zabbix-web-3.0.22]$ sudo httpd24-example.conf /etc/httpd/conf.d/zabbix.conf
sudo: httpd24-example.conf: コマンドが見つかりません
[vagrant@localhost zabbix-web-3.0.22]$ sudo cp httpd24-example.conf /etc/httpd/conf.d/zabbix.conf

Internal Server Error
なぜ?