Php
インストール
Mac
Composerは公式参照.
CakePHP
起動しようとしたときのエラー対応
You must enable the intl extension to use CakePHP
| You must enable the intl extension to use CakePHP. ~~ requirements.php on line 31
Fatal error: You must enable the intl extension to use CakePHP. in C:\xampp\htdocs\my_app\config\requirements.php on line 31
|
解決方法: 「php.ini」にある;extension=intl
を開放してXAMPP再起動.
No such file or directory ~~ index.php on line 31
自分のCakePHPアプリのディレクトリに移動してcomposer update
.
An Internal Error Has Occurred.
config/app.php
のデバッグレベルを以下のように変更.
| /*
* Debug Level:
*
* Production Mode:
* false: No error messages, errors, or warnings shown.
*
* Development Mode:
* true: Errors and warnings shown.
*/
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
|
Security::setSalt() must be of the type string, null given, called in~~
env
の第二引数に32文字指定.
| 'Security' => [
'salt' => env('SECURITY_SALT', 'dfc123c6c22d84f4bc12273f3df67c6ae55009696e4126b36ac2f755778faccc'),
],
|
Laravel
PHPとComposerのインストールまで済ませていること.
APIのエラー処理
Laravel Sail
OpenAPI
REPL(tinker)
| php artisan tinker
$user = App\Models\User::where("id", "=", "3500")->get();
$orders = App\Models\OrderHeader::where("id", "<", "3500")->get();
|
起動
| mysql.server start
php artisan serve
|
既にあるプロジェクトの導入
| composer install
php artisan migrate
php artisan key:generate
php artisan serve # 起動
|
開発環境ではhttp, 本番ではhttpsで接続
- 参考
- app/Providers/AppServiceProvider.phpを編集
| use Illuminate\Support\Facades\URL;
public function boot()
{
if (config('app.env') === 'production') {
\URL::forceScheme('https');
}
}
|
ユーザー作成
php artisan tinker
を実行 - REPLで次のように書く
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | $user = new User;
$user->name = "ユーザー名";
$user->email = "メールアドレス";
$user->password = Hash::make('パスワード');
$user->save();
$user = new User;
$user->name = "test";
$user->email = "test@phasetr.com"; # このメールアドレスは存在しない
$user->password = Hash::make('test');
$user->save();
$user = new User;$user->name = "user";$user->email = "user@phasetr.com";$user->password = Hash::make('test');$user->save();
$user = new User;$user->name = "admin";$user->email = "admin@phasetr.com";$user->password = Hash::make('test');$user->save();
$user = new User;$user->name = "shopper";$user->email = "shopper@phasetr.com";$user->password = Hash::make('test');$user->save();
|
| App\Models\User::first();
|
認証