I am new to Laravel development, and I spent the last 5 hours trying to get a Laravel project up and running using Docker (which apparently is obligatory). Every single time I try to create a new Laravel project using the provided curl
cmd, it says Docker is not running although it is. Literally spent the last hour browsing the internet for possible solutions, but nothing works.
Why do I have to install Docker, Debian & co on my Windows 10 machine for Laravel development?
3
Answers
If you want to use Laravel with the local server it’s absolutely fine.
You can use the composer command rather than the docker command.
If you want to use the docker command, you must have to install the docker in your PC and keep it running.
Here is the composer command:
composer global require laravel/installer
To run this command, you need composer installed. Use this link to download and install composer: https://getcomposer.org/
Laravel official Link: https://laravel.com/docs/8.x#the-laravel-installer
You don’t need Docker, it just (arguably) simplifies your development experience. Docker is a containerization solution where people create
images
that contain applications and packages which when deployed, provide an environment that meets their requirements. It’s kind of similar to virtualization, only it works closer to the hardware so is more performant.With Laravel the basic requirements are
PHP
,MySQL/MariaDB
, andApache/Nginx
. There are other packages people frequently use alongside Laravel such asRedis
,RabbitMQ
&Memcache
to name a few. LaravelSail
provides a wrapper around the Docker commands for starting and stopping containers (instances of Docker images) and some pre-configured environments.Sail
currently provides images forPHP 7.4
andPHP 8
andNginx
and a choice ofRDBMS
and some other things likeRedis
.By using
Sail
, you don’t need to install and configure these things on your host system. You installSail
then run a few commands to install the packages you want and away you go.Aside from simplifying the development experience, another nice added benefit is that you can create Docker environments for development and use the same image for production so you can be confident there will be no deployment issues (or at least shouldn’t be!).
Again, you don’t have to use Docker with Laravel. You are not missing out on anything by not using it, you just need to install and configure your environment manually on your host.
So in your scenario, if you were to not use
Sail
, you will need to installPHP
,Nginx
and eitherMySQL
orMariaDB
andComposer
at a minimum. Take a look at thisLEMP
installation tutorial on how to go about and then watch the Laravel 8 from Scratch series (or at least the environment setup part) for things likeComposer
.Interestingly, it seems that from Laravel 9 and above, they’ve removed the dedicated documentation section on composer installing to "Your First Laravel Project" section, right in the beginning. So you miss this entirely if you head on to the Linux or Windows install sections.
Insert your specific version or leave the version out for latest release: