Database
Lumen makes connecting with databases and running queries extremely simple. Currently Lumen supports four database systems: MySQL, Postgres, SQLite, and SQL Server.
You may use the configuration options in your .env
configuration file to configure your database settings, such as the driver, host, username, and password.
For example, without facades enabled, you may access a database connection via the app
helper:
Or, with facades enabled, you may access the database connection via the facade:
$results = DB::select("SELECT * FROM users");
Basic Queries
To learn how to execute basic, raw SQL queries via the database component, you may consult the full Laravel documentation.
Query Builder
Eloquent ORM
If you would like to use the Eloquent ORM, you should uncomment the $app->withEloquent()
call in your file.
Of course, you may easily use the full Eloquent ORM with Lumen. To learn how to use Eloquent, check out the .