Laravel without database connection

后端 未结 5 828
渐次进展
渐次进展 2020-12-31 18:42

is there a way to use Laravel without database connection? I am planning to create a frontend website using blade and VueJS that will consume third-party API and I don\'t ne

相关标签:
5条回答
  • 2020-12-31 19:22

    Every change you make to the .env file you need to restart your server.

    So you need to stop service by Ctrl + C, killing process if you run in detached state or stop your Docker etc. Then run again with php artisan serve or rerun your Docker container.

    0 讨论(0)
  • 2020-12-31 19:35

    This check appeared in Laravel 5.6.29, through the Ignition service's DefaultDbNameSolutionProvider.

    The solution message is a bit misleading, since it presumes you want to use a database. It's trying to convey that (a) you're configured to use a default database, and (b) that default database does not exist, so (c) you should change the database name to the actual value for your environment.

    Since you don't have a database, set DB_DATABASE=unused and you should not get this error any more. Of course, if you call DB::connection(), that will blow up. But that's expected.


    The two database names Laravel recognizes as default are "laravel" and "homestead".

    0 讨论(0)
  • 2020-12-31 19:40

    If you are using Homestead as your development environment, you should change DB_DATABASE from laravel to homestead, DB_USERNAME to homestead and DB_PASSWORD to secret.

    A homestead database is configured for both MySQL and PostgreSQL out of the box. To connect to your MySQL or PostgreSQL database from your host machine's database client, you should connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (PostgreSQL). The username and password for both databases is homestead / secret.

    https://laravel.com/docs/7.x/homestead#connecting-to-databases

    0 讨论(0)
  • 2020-12-31 19:40

    I know this is a bit late but if someone needs this when you update your .env file you must restart your server to effect those new setting so close current running server C+ctrl then again run PHP artisan serv

    0 讨论(0)
  • 2020-12-31 19:43

    if you using internal artisan service for development server, you need to restart service:

    Ctrl + c

    then run

    php artisan serve

    0 讨论(0)
提交回复
热议问题