Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 views
in Technique[技术] by (71.8m points)

php - Installing Laravel 4.1 in Windows 7 // Make .phar file globally available to windows command line

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:Windowssystem32laravel.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:wampwww).

Make a new project directory: www ew_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 ew_project folder:

C:> cd wampwww
ew_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:wampwww
ew_projectlaravel

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:in --the equivalent folder to /usr/bin on Linux. Copy the laravel.phar file in the C:in folder. Or , you can put it in a folder, such as, C:phplaravel.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...