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

warpig's avatar
Level 12

Trying to run Laravel on Windows

Hello guys I find myself in a very "saddening" situation which means my Macbook Pro charger died however the future is looking bright and I personally not gonna let that stop me from what I want to accomplish, the charger should arrive in 2 weeks. So I find myself using a Windows machine and turns out it's a completely different world as to how to set up Laravel and im having problems on how to setup this command "curl -s https://laravel.build/example-app | bash" I have:

  1. Installed Docker Desktop
  2. Windows Subsystem for Linux 2 (WSL2) is installed and enabled.
  3. And I even registered to a Windows program or whatever that means, I sincerely don't care about Windows programs outside of gaming (end of rant)
  4. I have Windows Terminal installed on my machine

But upon trying to run this command curl -s https://laravel.build/example-app | bash in my Projects folder the Windows Terminal had this message for me:

cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri:

So I found this answer on StackOverflow (thank GOD for SO) https://stackoverflow.com/questions/65312815/laravel-installation-sail-problem-23-failed-writing-body and there said I had to have installed a Linux distro on my Windows Machine, the answer pointed out to a URL which led me to download that said distro, Ubuntu 20.04.

I am now stuck.

  1. I have created a Linux username and password.

  2. I tried to run this curl -s https://laravel.build/example-app | bash in that Terminal window but it says: Unable to find image 'laravelsail/php80-composer:latest' locally and to be honest I don't think I should be running that command there, somehow you can type wsl in the Windows Terminal programme and you get a different name path, or source path I sincerely don't know what it's called, but upon entering wsl I get this: https://imgur.com/gx6QmaQ

  3. Well after thinking im a "real backend developer" (supposed to be a joke) I try entering that command and I get this: -sh: curl: not found

So, like I said the future is looking bright, I despise Windows but here I am, please HELP! I am willing to try and use TeamViewer if it's necessary.

0 likes
73 replies
warpig's avatar
Level 12

Some updates:

  1. I was getting that error because I didn't had "curl" installed, so I had to install it, I was able to instead install git on my Windows Machine and "curl" came with it, so I was able to install it by installing Git.
  2. If I run that same line again I now get this message:
$ curl -s https://laravel.build/example-app | bash
docker: Error response from daemon: the working directory 'C:/Program Files/Git/opt' is invalid, it needs to be an absolute path.
See 'docker run --help'.
bash: line 16: cd: example-app: No such file or directory

Please provide your password so we can make some final adjustments to your application's permissions.

bash: line 31: sudo: command not found

Thank you! We hope you build something incredible. Dive in with: cd example-app && ./vendor/bin/sail up

It seems like something went O.K. but there are a few lines that I don't understand. For example this:

  1. docker: Error response from daemon: the working directory 'C:/Program Files/Git/opt' is invalid, it needs to be an absolute path.
  2. bash: line 16: cd: example-app: No such file or directory
  3. bash: line 31: sudo: command not found

First of all, when I opened the Git terminal I was able to now navigate to my Windows Machine files and folders, so by using ls -lrt this command I was aware where I was in the Windows Machine, after it I was able to navigate to my temporary Projects folder and landed succesfully in Projects/ and this is where I once again tried to run this: curl -s https://laravel.build/example-app | bash

Just to try if that was succesfull, I try to run $ cd example-app && ./vendor/bin/sail up but already comes with this message:

bash: ./vendor/bin/sail: No such file or directory
warpig's avatar
Level 12

I don't know what happened, I think by installing the Git terminal, and thus curl getting inside the Windows machine somehow the Ubuntu terminal completed something, anyway I had a message:

Thank you! We hope you build something incredible. Dive in with: cd example-app && ./vendor/bin/sail up

Ran that and it's doing some things now. Hope that can get me a Laravel project up and running.

lemmon's avatar

@warpig I am interested to hear how this goes for you.

do you use docker on you apple?

1 like
warpig's avatar
Level 12

I did not had to use Docker at all @lemmon and that made me so happy, simply because I believe that if I don't have a need to do something with a tool, I simply don't mess with it but here we are :-).

Eventually I was able to finally produce a fresh new Laravel project on this Windows Machine, however upon cloning my repo to this very machine, I am now unable to run any artisan and naturally any php artisan commands, because somehow php or sail they are not found either on the:

  1. Gitbash terminal
  2. Windows terminal
  3. Powershell terminal

I miss the Mac days.

What I want to do now is to be able to browse a project I had on the Mac, but I can't get the php artisan serve to work.

lemmon's avatar

@warpig you need to be on a machine that has php installed on it.

open up git bash and type in php -v

if you get a version great if you do not then you have to get php on your machine for starters.

1 like
lemmon's avatar

@warpig

also composer.

when you install node you get npm. now you can compile assets etc.

2 likes
warpig's avatar
Level 12

if you get a version great if you do not then you have to get php on your machine for starters.

@lemmon I thought Sail installed "everything", so I need to install PHP, Composer and NPM... I see..

warpig's avatar
Level 12

Ok I get it I was simply following the docs from Laravel but I guess they were just pushing their service, I don't really care about it, but how do I even install php on this Windows Machine? If I want to use the Gitbash that is. For example if I run php -v on it I get: bash: php: command not found and I just haven't found exactly how to install php in bash..

lemmon's avatar
lemmon
Best Answer
Level 28

I ran into the fact that installing php on a windows machine was a task so

The way I installed php on my machine is I installed wampserver

wamp server is a linux apache mysql php server that runs on windows that comes with phpmyadmin and mysql cmd prompt.

https://www.wampserver.com/en/

you could actually use that to serve laravel but if you are used to php artisan serve then wamp installs php so you can get composer going

lemmon's avatar

@warpig

The way I installed php on my machine is I installed wampserver

wamp server is a linux apache mysql php server that runs on windows that comes with phpmyadmin and mysql cmd prompt.

https://www.wampserver.com/en/

you could actually use that to serve laravel but if you are used to php artisan serve then wamp installs php so you can get composer going

1 like
warpig's avatar
Level 12

Thank you I will try to install this.

lemmon's avatar

install wamp then you should be abled to run php in git bash then you can install composer using git bash. then move the composer.phar like the instructions say.

2 likes
warpig's avatar
Level 12

@lemmon Finally got it my friend I have succesfully installed Composer and PHP on this Windows Machine, thanks! I should now go ahead and create a new Laravel project and well I hope I can make it through until my new charger arrives! So I just need to install Laravel through Composer is that correct?

I need to move composer.phar? Well I need to know what my PATH is, how can i print that into the console?

warpig's avatar
Level 12

@lemmon I get this

warpig@DESKTOP-BR5EUFO MINGW64 ~/projects
$ mv composer.phar /usr/local/bin/composer
mv: cannot stat 'composer.phar': No such file or directory

lemmon's avatar

composer create-project --prefer-dist laravel/laravel NameOfYourProject

or install the laravel installer

lemmon's avatar

looks like you are in the projects dir you need to be in ~

lemmon's avatar

@warpig

type cd and it will put you home then do ls and you should see the .phar file so no you can mv the file where it says to.

warpig's avatar
Level 12

Right now that is not important, I need to know why I can't run php artisan serve

warpig@DESKTOP-BR5EUFO:/mnt/c/Users/warpig/projects/videotheque$ php artisan make:controller Test
PHP Warning:  require(/mnt/c/Users/warpig/projects/videotheque/vendor/autoload.php): failed to open stream: No such file or directory in /mnt/c/Users/warpig/projects/videotheque/artisan on line 18
PHP Fatal error:  require(): Failed opening required '/mnt/c/Users/warpig/projects/videotheque/vendor/autoload.php' (include_path='.:/usr/share/php') in /mnt/c/Users/warpig/projects/videotheque/artisan on line 18
warpig's avatar
Level 12

@lemmon So right now im at /home/warpig how can I go back to home? I can't by cd -- or cd - or cd ~

warpig's avatar
Level 12

PHP is installed... that works right now.

warpig's avatar
Level 12

Composer version 2.0.12 2021-04-01 10:14:59

lemmon's avatar

@warpig

warpig@DESKTOP-BR5EUFO:/mnt/c/Users/warpig/projects/videotheque

see where it say's mnt?

that means you are inside wsl.

warpig's avatar
Level 12

warpig@DESKTOP-BR5EUFO MINGW64 ~
$ cd

warpig@DESKTOP-BR5EUFO MINGW64 ~
$ ls
'3D Objects'/
 AppData/
'Application Data'@
 Contacts/
 Cookies@
'Creative Cloud Files'/
 Desktop/
 Documents/
 Downloads/
 Favorites/
 Links/
'Local Settings'@
 MicrosoftEdgeBackups/
 Music/
'My Documents'@
 NTUSER.DAT
 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TM.blf
 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000001.regtrans-ms
 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000002.regtrans-ms
 NetHood@
 OneDrive/
 Pictures/
 PrintHood@
 Projects/
 Recent@
'Saved Games'/
 Searches/
 SendTo@
'Start Menu'@
 Templates@
 Videos/
 ansel/
 composer.bat
 dev/
 ext/
 extras/
 getting-started/
 lib/
 ntuser.dat.LOG1
 ntuser.dat.LOG2
 ntuser.ini
 php/

warpig@DESKTOP-BR5EUFO MINGW64 ~
$ mv composer.phar /usr/local/bin/composer
mv: cannot stat 'composer.phar': No such file or directory

lemmon's avatar

first of all run php -v and tell me what happens.

lemmon's avatar

@warpig

go to git bash and do

php -v

composer --version

what happens?

warpig's avatar
Level 12
warpig@DESKTOP-BR5EUFO MINGW64 ~
$ php -v
PHP 8.0.3 (cli) (built: Mar  2 2021 23:33:56) ( NTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies

warpig@DESKTOP-BR5EUFO MINGW64 ~
$ composer --version
Composer version 2.0.12 2021-04-01 10:14:59
lemmon's avatar

@warpig Now I think the project you have in ~/Projects was created with the wsl and sail am I correct?

warpig's avatar
Level 12

Yes that "test drive" project was created with WSL in Visual Studio Code terminal.

lemmon's avatar

so now find a spot where you wan to put your project cd in there and run

composer create-project --prefer-dist laravel/laravel NameOfYourProject

warpig's avatar
Level 12
$ composer create-project --prefer-dist laravel/laravel NameOfYourProject
Creating a "laravel/laravel" project at "./NameOfYourProject"
Installing laravel/laravel (v8.5.15)
  - Installing laravel/laravel (v8.5.15): Extracting archive
Created project in C:\Users\warpig\projects\NameOfYourProject
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework[v8.12.0, ..., 8.x-dev] require league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.0, ..., 1.x-dev].
    - league/flysystem[1.1.0, ..., 1.x-dev] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - Root composer.json requires laravel/framework ^8.12 -> satisfiable by laravel/framework[v8.12.0, ..., 8.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\Users\warpig\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
lemmon's avatar

@warpig

so now find a spot where you wan to put your project cd in there and run

composer create-project --prefer-dist laravel/laravel NameOfYourProject

warpig's avatar
Level 12

All services running, the icon is green

lemmon's avatar

@warpig

click on the green icon then choose php from the menu then open up the php.ini file.

then do ctrl + f and search for fileinfo extension when you find it remove the ; from in front of it to enable it

ie change:

;extension=fileinfo

to

extension=fileinfo

save the file close it

then click on green icon and choose restart all services

then run composer create-project again

warpig's avatar
Level 12
warpig@DESKTOP-BR5EUFO MINGW64 ~/projects
$ composer create-project --prefer-dist laravel/laravel NameOfYour
Creating a "laravel/laravel" project at "./NameOfYour"
Installing laravel/laravel (v8.5.15)
  - Installing laravel/laravel (v8.5.15): Extracting archive
Created project in C:\Users\warpig\projects\NameOfYour
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework[v8.12.0, ..., 8.x-dev] require league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.0, ..., 1.x-dev].
    - league/flysystem[1.1.0, ..., 1.x-dev] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - Root composer.json requires laravel/framework ^8.12 -> satisfiable by laravel/framework[v8.12.0, ..., 8.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\Users\warpig\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

warpig@DESKTOP-BR5EUFO MINGW64 ~/projects

1 like
lemmon's avatar

@warpig

then let me know what happens. hopefully it works or the error changes. if there is another error post it.

warpig's avatar
Level 12

It's not there, this is the output of that:

warpig@DESKTOP-BR5EUFO MINGW64 ~/projects
$ php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
filter
gmp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]
lemmon's avatar

type php -i

and find the 'Loaded Configuration File'

should be only a few lines from the top;

mine is

Loaded Configuration File => C:\wamp64\bin\php\php7.4.9\php.ini

warpig's avatar
Level 12

Loaded Configuration File => C:\Users\warpig\php\php.ini

should I go there now and do the same with fileinfo extension ?

lemmon's avatar

@warpig

Yes make sure this list is satisfied

BCMath PHP Extension

Ctype PHP Extension

Fileinfo PHP extension

JSON PHP Extension

Mbstring PHP Extension

OpenSSL PHP Extension

PDO PHP Extension

Tokenizer PHP Extension

XML PHP Extension

if they are in the ini file then remove the colon from the beginning

warpig's avatar
Level 12

Ok the command works now, I have a new Laravel application. How can I ensure php artisan are working now?

lemmon's avatar

@warpig

cd into the application and type

php artisan -v

or

php artisan list

warpig's avatar
Level 12

@lemmon they work on new Laravel's but not in the cloned repo...

lemmon's avatar

@warpig

so when you clone a repo from git you have to:

cd into the repo

cp .env.example .env

composer install

php artisan key:generate

then you can run php artisan serve inside the project

1 like
warpig's avatar
Level 12

Thank you Mr. Lemmon you saved my project !!

lemmon's avatar

@warpig

Or better yet

go to the green icon and click on it then click on php

hover over extensions and there will be a list of extensions you can enable.

repeat the process for each extension in the list above that you can find

then click on the green icon and select restart all services.

warpig's avatar
Level 12

Hi @lemmon yes you are right sorry I couldn't respond it was 11 PM where I live I hope you have the time to guide me again, I would appreciate it my friend

lemmon's avatar

Mark a best reply and start another thread.

lemmon's avatar

With my limited knowledge of wsl and docker for windows. I agree.

1 like
warpig's avatar
Level 12

@sourcefli Getting to install Laravel through this method was painful for me mainly because of 2 things but I don't need to get into it, mainly because I was frustrated and just wanted to overcome this challenge since I didn't know when I was going to get the Mac back. Eventually @lemmon showed me the ultimate basics and that was a heaven sent, installing Wamp is probably the most straight forward method there is, at least to get your feet wet.

Laragon would've seem like a great choice as you say is very "laravel-esque" but I use this Windows Machine for gaming, had nothing about web dev in here.

vinhnt13's avatar

@warpig @lemmon I have same issue when i create laravel project. But one this way i run command line on linux kernel of windows. Project was created

Please or to participate in this conversation.