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 need a database.
Currently, I am getting this error and I am not sure how to bypass it.
Database name seems incorrect
You're using the default database name laravel. This database does not exist.
Edit the .env file and use the correct database name in the DB_DATABASE key
Of course you can use Laravel without a database. You can read and save data using remote RESTful API, files etc or you can do not use any data layer at all. Laravel will work just fine. Also, you can use pretty cool SQLite library which allows you to save all info to a single file.
Echo the Laravel database name in Blade/PHP This will output the name of the database or return 'none' if there is no connection. If you view it in the browser, it gives you the name of the connected database. Checking whether the application is connected to a Laravel database.
Laravel makes connecting with databases and running queries extremely simple. The database configuration file is app/config/database. php . In this file you may define all of your database connections, as well as specify which connection should be used by default.
Laravel does not support MongoDB by default.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With