Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel without database connection

Tags:

laravel

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
like image 716
user2496520 Avatar asked Sep 12 '19 13:09

user2496520


People also ask

Can Laravel run without database?

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.

How check Laravel database connected or not?

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.

How does Laravel connect to 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.

Which database is not natively supported by Laravel?

Laravel does not support MongoDB by default.


1 Answers

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

like image 149
Liel van der Hoeven Avatar answered Nov 02 '22 09:11

Liel van der Hoeven