Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

xprogrammerx's avatar

Create a totally empty project with laravel new

Hello guys , i decided to switch to Laravel and PHP.

And i hope you can give me some support as i will be needing a lot

I think i managed to install LAMP environment(Linux Apache MySql Php) correctly now the only problem is that when i create a new laravel project with the command laravel new , it has so many pre-configuration like it tries to connect to a MySql Database and therefore get an error when i visit the page (it dosent have an account on the db).

I don't want that, i want to create an empty Laravel skeletton project without any connection to database ....i will make that later as i'm learning.

I was wandering if there is an option to give to the laravel new command to make an empty project.

By the way creating a project with composer works fine , yet i was wandering is there a difference creating a project with composer or with the laravel installer?

0 likes
13 replies
MohamedTammam's avatar

Laravel will not use its database connection if it isn't needed. Where are you using database connection? Can you please share the error logs.

jlrdw's avatar

Change session to file.



    /*
    |--------------------------------------------------------------------------
    | Default Session Driver
    |--------------------------------------------------------------------------
    |
    | This option determines the default session driver that is utilized for
    | incoming requests. Laravel supports a variety of storage options to
    | persist session data. Database storage is a great default choice.
    |
    | Supported: "file", "cookie", "database", "apc",
    |            "memcached", "redis", "dynamodb", "array"
    |
    */

    'driver' => env('SESSION_DRIVER', 'file'),

    /*

Here or in .env, whichever you use.

puklipo's avatar

SQLite is the default in Laravel 11. Does not connect to MySQL. Do not select MySQL during installation.

laravel/installer 5.8.1

First choice.

  • Laravel Breeze
  • Blade with Alpine
  • PHPUnit
  • SQLite

The installer executes composer create-project at the end. It's the same either way.

Node.js is also required to use Laravel. Apache is not required.

jlrdw's avatar

@puklipo Node.js is optional. But if using some of the packages then it is required.

DhPandya's avatar

@xprogrammerx Just use SQLite while setting up the latest Laravel app. Don't select any starter kits to keep it simple.

xprogrammerx's avatar

Hello guys, thank you for your responses.

So here is the thing , when using the laravel new command with these choices this is what happens :

Database type -> sqlite run database migration -> No

Result page

Database file at path [/home///testproject/database/database.sqlite] does not exist. Ensure this is an absolute path to the database.

select * from "sessions" where "id" = JJt055oXsR54FOwQGzdmLWwLhMwkrUjrbWCez3yp limit 1

With these choices this is what happens :

Database type -> sqlite run database migration -> Yes

Result page

Everything is fine!

With these choices this is what happens :

Database type -> mysql run database migration -> No or Yes

Result page :

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

You see what's happening here ,it needs a database at least sqlite. In a nutshell i need to know why does laravel needs this database initially ? for sessions? migrations ? And is there not an option to skip it and create an empty project?

jlrdw's avatar

@xprogrammerx You could always just install using composer then customize whatever you need.

1 like
xprogrammerx's avatar

@jlrdw Still it will create a sqlite database ,i've checked it.

So i have to know what does it need that database for? sessions?migrations?

How can i make it use my MySql database instead , i think i should create a user for the app and pass it to laravel somehow during creation of a new project.

jlrdw's avatar

@xprogrammerx

So i have to know what does it need that database for?

Nothing, laravel doesn't need sqlite.

colbyalbo's avatar
colbyalbo
Best Answer
Level 10

@xprogrammerx to create a laravel 11 app, with the default sqlite db driver:

  1. make sure your dev environment php.ini has the pdo_sqlite & sqlite3 extensions enabled
  2. run composer create-project laravel/laravel example-app
  3. in the .env, change the sessions constant to SESSION_DRIVER=file (or keep it as is, but you would need to run migrate)

If you want to disable the database all together:

  1. run composer create-project laravel/laravel example-app
  2. in the .env, change the sessions constant to SESSION_DRIVER=file
  3. in the .env, change the db constant to DB_CONNECTION=null
1 like
colbyalbo's avatar

also if you eventually want to connect a MySql db, edit the following in the .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_db_name
DB_USERNAME=root
DB_PASSWORD=
xprogrammerx's avatar

All right i see things clearly now , thank you all.

Please or to participate in this conversation.