i have some problems installing Laravel 4.1 in Windows 7 via the first method explained in the Laravel documentation ( http://laravel.com/docs/installation#install-laravel ).
So I downloaded the laravel.phar file and put it in my path ( System32 ). Which would be the equivalent of /usr/bin in linux based systems?
( I also added .PHAR in the PATHEXT system variable ).
When i ran the laravel command from the command line it didn't know how to open it, so i chose to open it with php.exe. Now, when I run the composer command it says: "Could not open input file: C:\Windows\system32\laravel.phar".
I suppose it's less a problem with laravel itself but my limited knowledge of the Windows command line. The installation via composer works fine.
Any help is appreciated.
To rephrase and clarify this question: How do I make a .phar file globally available to the Windows command line?
Phar allows you to put an entire PHP application into a PHP Archive. It is not a direct executable as you may assume.
To install Laravel 4.1 successfully on Windows 7, you need Composer -a package manager. First install Composer. This will install globally on your system. Composer can now be called through your command prompt via 'composer'.
Next, go to where your WAMP or XAMP project folder is -generally, this would be your www folder (i.e. C:\wamp\www).
Make a new project directory: www\new_project. Now go to your start menu and run cmd as admin. Next you need to change your directory to the C drive and then into your www\new_project folder:
C:\> cd wamp\www\new_project
Now you can take advantage of composer by calling:
composer create-project laravel/laravel --prefer-dist
Call the above statement in that new_project folder because that is where laravel will install. The above will make your directory path as:
C:\wamp\www\new_project\laravel\
Laravel is now available on your system. You can verify a successful install by going to:
http://localhost/new_project/laravel/public/
Based on the above question edit regarding making a .phar globally available for command:
The directory your looking for is
C:\bin
--the equivalent folder to /usr/bin
on Linux.
Copy the laravel.phar
file in the C:\bin folder
. Or , you can put it in a folder, such as, C:\php\laravel.phar
. Then you need to make a batch file somewhere within the PATH called laravel.bat
which will then do the following:
@ECHO OFF
php "%~dp0laravel.phar" %*
The "%*" repeats all of the arguments passed to the shell script. Thus, you can run 'laravel new project'. Hope this points you in the right direction.
The documentation on the Laravel website is not a good way to install laravel on windows. You'll got problem with the routing later.
Accessing laravel URL like this is a no-no:
http://localhost/new_project/laravel/public/
to get a better URL you must setup Apache Virtual Host
and edit hosts file
.
The best way to install Laravel on windows is to use Git and Composer. if you already successfully install Git
and Composer
, open Git bash
and using ls
and cd
terminal command go to c:\xampp\htdocs
folder
and run this command (it will ask you for your Git passphrase, make sure you install your Git properly - tutorial here - http://www.thegeekstuff.com/2012/02/git-for-windows/):
git clone [email protected]:laravel/laravel.git laraveldev
It will download laravel into a folder name laraveldev in htdocs:
c:\xampp\htdocs\laraveldev
Use the Git bash terminal to install laravel into PHP using this command:
composer install
edit hosts file - located in c:\windows\system32\drivers\etc
, add this:
127.0.0.1 www.laravel.dev
and put virtual hosts entry in c:\xampp\apache\conf\extra\httpd-vhosts.conf
.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/laraveldev/public"
ServerName www.laravel.dev
ServerAlias www.laravel.dev
ErrorLog "logs/laravel.log"
CustomLog "logs/custom.laravel.log" combined
<Directory "C:/xampp/htdocs/laraveldev/public">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Restart you xampp apache. Then you can access laravel app in your browser like this:
http://www.laravel.dev
I'm totally 100% sure you'll got those "You have arrived"
text :D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With