Hi Laracasts, I will soon be making an API with Lumen and I decided to setup a project on my laptop for some practice before I setup the real project at work. I wanted to get some database interaction so I installed sqlite. I've never used it, but I know mysql and aside that, I just want the drivers to work so that I can interact with it through eloquent. Right now in my .env file, I have this configuration.
DB_CONNECTION=sqlite
DB_FILE=db.sql
When I run php artisan migrate, I get:
[InvalidArgumentException]
Database does not exist.
What other configuration do I need more for sqlite? Also, what do I need for mysql? That's what I'll be using for work.
In Lumen there is no config folder. It is all declared in your .env file. I renamed the file database.sqlite and made all the other necessary changes and I got a different error:
Lumen makes connecting with databases and running queries extremely simple. Currently Laravel supports four database systems: MySQL, Postgres, SQLite, and SQL Server.
You may use the DB_* configuration options in your .env configuration file to configure your database settings, such as the driver, host, username, and password.
Note: In order for your configuration values to be loaded, you will need to uncomment the Dotenv::load() method call in your bootstrap/app.php file.
I got it. Thanks for all the help. I changed localhost to 127.0.0.1 and now I'm able to run database migrations. Here's what my .env file looks like for anyone who is interested or may be having the same problem:
Sorry about the confusion. I probably should have explained a little more. At work I'm setting up a project in Lumen. It's the first Lumen project that I've done so I wanted to get my feet wet by making one at home. I didn't want to install mysql and so I tried to use sqlite. I wasn't able to resolve it last night and so now that I'm at work the question is still relevant, but I needed to verify for mysql, not sqlite, since it's a different database here at work. Honestly, I wanted to know how to do both anyway. At work we use mysql but I wanted to know about sqlite as well so that I could make up a quick example at home whenever I need to.
I had this issue with postgres. The solution is to run migrations from inside your Vagrant/Homestead box, as it (should) contains all the appropriate drivers. It surely will if you are using Homestead.