How to generate .env file for laravel?

前端 未结 10 1041
不知归路
不知归路 2020-12-24 05:39

From the documentation I see it\'s possible to create a laravel project via laravel installer:

$laravel new blog

or via composer:



        
10条回答
  •  一整个雨季
    2020-12-24 06:11

    This is an old thread, but as it still gets viewed and recently active "26" days ago as of this post, here is a quick solution.

    There is no .env file initially, you must duplicate .env.example as .env.

    In windows, you can open a command prompt aka the CLI and paste the exact code below while inside the root directory of the project. Must include the ( at the start line without space.

    (
    echo APP_NAME=Laravel
    echo APP_ENV=local
    echo APP_KEY=
    echo APP_DEBUG=true
    echo APP_URL=http://localhost
    echo.
    echo LOG_CHANNEL=stack
    echo.
    echo DB_CONNECTION=mysql
    echo DB_HOST=127.0.0.1
    echo DB_PORT=3306
    echo DB_DATABASE=homestead
    echo DB_USERNAME=homestead
    echo DB_PASSWORD=secret
    echo.
    echo BROADCAST_DRIVER=log
    echo CACHE_DRIVER=file
    echo SESSION_DRIVER=file
    echo SESSION_LIFETIME=120
    echo QUEUE_DRIVER=sync
    echo.
    echo REDIS_HOST=127.0.0.1
    echo REDIS_PASSWORD=null
    echo REDIS_PORT=6379
    echo.
    echo MAIL_DRIVER=smtp
    echo MAIL_HOST=smtp.mailtrap.io
    echo MAIL_PORT=2525
    echo MAIL_USERNAME=null
    echo MAIL_PASSWORD=null
    echo MAIL_ENCRYPTION=null
    echo.
    echo PUSHER_APP_ID=
    echo PUSHER_APP_KEY=
    echo PUSHER_APP_SECRET=
    echo PUSHER_APP_CLUSTER=mt1
    echo.
    echo MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
    echo MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
    )>".env"
    

    Just press enter to exit the prompt and you should have the .env file with the default settings created in the same directory you typed above CLI command.

    Hope this helps.

提交回复
热议问题