公開日 2020.11.3カテゴリ:Laravelタグ:PHP,Laravel,Factory
Laravel 6 ユニットテストをする際 Docker Compose の環境変数を上書きできずにはまったが phpunit.xml ドキュメントを読んで解決した まとめ <php> 要素 (PHP INI 項目や定数、グローバル変数の設定) では、既存の環境変数は上書きされない。上書きしたいならば、 force 属性を使う。 ドキュメントはこちら。といいますか、 phpunit.xml で検索して最初のページでした。 3. XML 設定ファイル — PHPUnit latest Manual ハマっていた内容 Docker Compose で立ち上げたコンテナ内に Laravel 6 を構築しています。 コンテナ内で PHPUnit を実行したとき、接続データベースがテスト用のインメモリ SQLite ではなく、開発や運用時に使う通常のデータベースとなっていました。 Laravel か
はじめに ウェブアプリケーションフレームワークのクラス構成にはさまざまなバリエーションがありますが、どれも様々なデザインパターンを駆使し、素晴らしいクラス構成になっています。 今回、じっくりフレームワークのソースコードを読むことで、少しでもいいクラス設計について学べるといいなぁと思い、このような企画を思いつきました。 PHP には様々なウェブアプリケーションフレームワークがあり、それぞれに特徴がありますが、今回は、近年突出して注目されている Laravel を取り上げます (いずれ他のフレームワークでも試してみたいです)。 環境 PHP 5.6.9 Laravel 5.2 やったこと Eloquent (Active Record) と DBファサード (Query Builder) の使い分け、ついでに Repository について Dependency Injection と Ser
Laravelってなんだよ って人はこの記事みないと思うので割愛しますが、気になる人は勝手に調べてください 前置き長いので気になる人はここまで飛ばしてください つい先日からLaravel開発する機会があったのですが、環境を汚さないようにとDockerでコンテナ立ち上げて、その中でゴニョゴニョやっていこうかなと思ってみていたらLaradockというものにたどり着きました。 ふーん、便利じゃん 早速ドキュメントに従ってやってみました。 gitクローンして!envファイルコピーして!docker立ち上げて!envファイル書き換えて!Let's Enjoy ! :) localhostにつないでね! ・ ・ ・ 404・・・? enjoyできないんだが!!!! なぜLaradockでエンジョイ出来なかったのか 色々試しましたがどうも上手く行きません。 php artisan serve・・・ダメで
普段使われているフレームワーク等に、簡単にlaravel4のコンポーネントを組込む事が出来ます。 なかでもおすすめなのはDIコンテナとしても軽量、かつ簡単なilluminate/containerと、 illuminate/databaseです。 今回はdatabaseを実際に使ってみます。 導入方法はいつものcomposer require __DIR__ . "/vendor/autoload.php"; use Illuminate\Database\Capsule\Manager as DatabaseManager; class Database { protected $db; // public function __construct() { $this->db = new DatabaseManager; } public function connect() { $th
Laravel 4 でデータベースを使ったテストを書く際の Tips です。 自動テストでデータベースにアクセステストを書く際に大切なのが、データベーステーブルのデータをテストで想定された状態にしておくということです。テーブルの内容がテストを実行される度に異なると、ある時はテストが通って、ある時は通らないという状態になります。 この「想定された状態」をセットアップするために、フレームワークで用意されている Migration と Seeder を利用しています。 テストケースでマイグレーション実行 開発を進めていると、データベーススキーマを変更する場合があります。マイグレーションファイルを作成して、php artisan migrate コマンドで適用するのことになります。テスト用データベースについても適用する必要がありますが、php artisan migrate --env=testi
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く