PS C:\MAMP\htdocs\step01> cd umarche
PS C:\MAMP\htdocs\step01\umarche> php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Tue Apr 2 10:37:07 2024] PHP 8.2.9 Development Server (http://127.0.0.1:8000) started
PS C:\MAMP\htdocs\step01\umarche> git switch -c sec01_initialSetting
Switched to a new branch 'sec01_initialSetting'
PS C:\MAMP\htdocs\step01\umarche> git branch
main
* sec01_initialSetting
タイムゾーン 言語設定
config/app.phpを編集
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Asia/Tokyo',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'Ja',
PS C:\MAMP\htdocs\step01\umarche> git add -A
warning: in the working copy of 'composer.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'composer.lock', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'config/app.php', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'storage/debugbar/.gitignore', LF will be replaced by CRLF the next time Git touches it
PS C:\MAMP\htdocs\step01\umarche> git switch -c sec02_larabelBreeze
Switched to a new branch 'sec02_larabelBreeze'
PS C:\MAMP\htdocs\step01\umarche> git branch
main
sec01_initialSetting
* sec02_larabelBreeze
PS C:\MAMP\htdocs\step01\umarche>
▼composerでLaravel Breezeのパッケージをインストール
composer require laravel/breeze "1.*" --dev
PS C:\MAMP\htdocs\step01\umarche> composer require laravel/breeze "1.*" --dev
./composer.json has been updated
Running composer update laravel/breeze
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking laravel/breeze (v1.10.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/breeze
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
80 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
No security vulnerability advisories found.
▼アセットをコンパイル
PS C:\MAMP\htdocs\step01\umarche> php artisan breeze:install
Breeze scaffolding installed successfully.
Please execute the "npm install" && "npm run dev" commands to build your assets.
PS C:\MAMP\htdocs\step01\umarche> npm install
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
added 805 packages, and audited 806 packages in 34s
102 packages are looking for funding
run `npm fund` for details
1 moderate severity vulnerability
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
PS C:\MAMP\htdocs\step01\umarche> npm run dev
> dev
> npm run development
> development
> mix
● Mix █████████████████████████ emitting (95%)
emit
● Mix █████████████████████████ done (99%) plugins
WebpackBar:done
✔ Mix
Compiled successfully in 3.27s
Laravel Mix v6.0.49
✔ Compiled Successfully in 3254ms
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐
│ File │ Size │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ /js/app.js │ 707 KiB │
│ css/app.css │ 31.8 KiB │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┘
Containing the word:
Table Ascending Action Rows Type Collation Size Overhead
failed_jobs Browse Browse Structure Structure Search Search Insert Insert Empty Empty Drop Drop 0 InnoDB utf8_general_ci 16.0 KiB -
migrations Browse Browse Structure Structure Search Search Insert Insert Empty Empty Drop Drop 4 InnoDB utf8_general_ci 16.0 KiB -
password_resets Browse Browse Structure Structure Search Search Insert Insert Empty Empty Drop Drop 0 InnoDB utf8_general_ci 16.0 KiB -
personal_access_tokens Browse Browse Structure Structure Search Search Insert Insert Empty Empty Drop Drop 0 InnoDB utf8_general_ci 16.0 KiB -
users Browse Browse Structure Structure Search Search Insert Insert Empty Empty Drop Drop 0 InnoDB utf8_general_ci 16.0 KiB -
5 tables Sum 4 InnoDB utf8_general_ci 80.0 KiB 0 B
基本的なLaravelのMVC
モデルを作成する
「todo_lists」というテーブルを作成
▼モデルとマイグレーションファイルとコントローラーを同時に作成
php artisan make:model TodoList -mc
下記の通り3つのファイルを作成されます
INFO Model [C:\Users\xxxxxx\laravel_test\app/Models/TodoList.php] created successfully.
INFO Migration [C:\Users\xxxxxx\laravel_test\database\migrations/2024_02_27_120807_create_todo_lists_table.php] created successfully.
INFO Controller [C:\Users\xxxxxx\laravel_test\app/Http/Controllers/TodoListController.php] created successfully.
<?php
use Illuminate\Support\Facades\Route;
use App\Models\TodoList;//追記
use App\Http\Controllers\TodoListController;//追記
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/list', [TodoListController::class, 'index']);
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tasks', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->boolean('status')->default(false);
$table->timestamp('updated_at')->useCurrent()->nullable();
$table->timestamp('created_at')->useCurrent()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tasks');
}
};