LoginSignup
0
0

Laravel勉強日記

Posted at

一からサイト作成の流れをまとめる

dockerの起動

仮想環境の開発のため

プロジェクトの作成

まず、ターミナルを zshから、bashに切り替える
その後以下のコマンドでファイルを作成する。

.ターミナル
 curl -s https://laravel.build/test-project | bash  //test-projectはファイル名

ホームディレクトリにファイルが作成される。
(作業しやすいようにデスクトップに移動させたほうがいいかも)

画面の表示

cdコマンドで作成したディレクトリに移動する

$ cd /Users/x21024xx/Desktop/test-project 

Laravel Sail の起動

test-project x21024xx$ ./vender/bin/sail up -d

phpMyAdminの追加

phpMyAdimn があればsql文の専門的な知識がなくてもWebブラウザ上で視覚的にデータベースを管理できる。
Laravel Sail を停止して,docker-compose.yml を編集する。 ファイルは直下にある。

mysql:
        image: 'mysql/mysql-server:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ROOT_HOST: '%'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 1
        volumes:
            - 'sail-mysql:/var/lib/mysql'
            - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
        networks:
            - sail
        healthcheck:
            test:
                - CMD
                - mysqladmin
                - ping
                - '-p${DB_PASSWORD}'
            retries: 3
            timeout: 5s

以下の部分

phpmyadmin:
        image: phpmyadmin/phpmyadmin
        links:
            - mysql:mysql
        ports:
            - 8080:80
        environment:
            MYSQL_USERNAME: '${DB_USERNAME}'
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            PMA_HOST: mysql
        networks: 
            - sail
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sail-redis:/data'
        networks:
            - sail
        healthcheck:

のphpmyadminの部分を追加する

phpmyadminへログイン  

Webブラウザで以下のURLにアクセスする
ポート番号は上で決めたものになる

http://localhost:8080/

ユーザ名とパスワードを登録する。.envファイルで確認可能 

メッセージの日本語化

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',

    /*
    |--------------------------------------------------------------------------
    | Application Fallback Locale
    |--------------------------------------------------------------------------
    |
    | The fallback locale determines the locale to use when the current one
    | is not available. You may change the value to correspond to any of
    | the language folders that are provided through your application.
    |
    */

    'fallback_locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Faker Locale
    |--------------------------------------------------------------------------
    |
    | This locale will be used by the Faker PHP library when generating fake
    | data for your database seeds. For example, this will be used to get
    | localized telephone numbers, street address information and more.
    |
    */

    'faker_locale' => 'ja_JP',

翻訳ファイルの置き場所はプロジェクト直下のlangファイル。
スクリーンショット 2023-10-12 15.33.43.png
完成イメージはこんな感じ
以下のコマンドで日本語パッケージ化可能

$ ./vendor/bin/sail artisan lang:publish

$ ./vendor/bin/sail composer require laravel/breeze --dev

$ ./vendor/bin/sail artisan breeze:install

$ ./vendor/bin/sail artisan migrate

$ ./vendor/bin/sail composer require askdkc/breezejp --dev

$ ./vendor/bin/sail artisan breezejp


参考:https://github.com/askdkc/breezejp

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0