Laravel Setup Isshue and composer Isshue on windows - laravel

Not able to create new laravel project.
C:\Users\Devil>composer global require "laravel/installer"
Changed current directory to C:/Users/Devil/AppData/Roaming/Composer
[ErrorException]
file_put_contents(): Filename cannot be empty
global <command-name> [<args>]...
C:\Users\Devil>laravel new blog
'laravel' is not recognized as an internal or external command,
operable program or batch file.
Please Help Me on this

1 - Install composer. In case it is not yet installed here is the easiest way to install composer on windows
2 - Go to your folder where you save your projects through the command line and run this command: composer create-project --prefer-dist laravel/laravel project-name . This will create a new folder project-name
3 - Access the project-name folder through the command line and run php artisan serve
4 - Open your browser and access http://localhost:8000

Related

Composer Installation Error on Windows 10: The installation directory is not writable

I try to install Composer (downloaded from https://getcomposer.org/download/) on Windows 10, but I get the following error message: The installation directory "C:\Users\BAB2~1\AppData\Local\Temp\is-5EP2P.tmp" is not writable.
Composer Installation Error
I have given full access to this directory, but it doesn't help. Could you please suggest any ways to solve this problem.
download https://getcomposer.org/composer.phar
drop composer.phar file into your PHP folder
make sure this PHP folder is on-path (so that you can call php everywhere)
if not, add the PHP folder to your environment PATH variable
run php composer.phar for testing. you should get Composer's help output
create a little batch file composer.bat to invoke composer easier:
C:\PHP> echo #php "%~dp0composer.phar" %*>composer.bat
This enables you to run composer in any PHP project folder.

composer suddenly doesn't work on cmd

I was trying to install laravel after i installed composer and made sure it's working by typing composer on my cmd but right after i added this line on cmd i became unable to see composer command working
composer global require "laravel/installer"
Now when i type composer it does nothing just like that
And here list of the current windows variables
The problem was that there was 2 files composer.phar and composer.bat inside my user folder "C:\Users\Yasser" which opens on cmd by default when i removed these 2 files i was able to use the command composer normally thanks to Peh

Install Laravel using Composer

I'm trying to install Laravel using Composer, but after running the following command
composer create-project laravel/laravel cmsLaravel 5.2
pointing to my c/xampp/htddocs directory, I get the error below:
C:\xampp\htdocs\laravelCMS\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravelCMS\bootstrap\autoload.php on line 17
To install Laravel using composer, all you need to do is to run in your terminal is:
composer create-project --prefer-dist laravel/laravel blog
Where: blog is the name of the folder containing your new Laravel instance.
To install Laravel directly within your chosen directory (not in a folder within it as demonstrated above), simply run the same command but this time without a folder name as in:
composer create-project --prefer-dist laravel/laravel
Remember to run the command within your desired directory for the project; in your case, for C:\xampp\htdocs\, then, run either the first or second command as above base on your needs.
This assumes you already have Composer properly installed as recommended on their website.
Before you try addressing your failed to open stream: error, do avoid having folder names with space(s) as in your command above (obviously not the source of the error).
Make sure you have the correct Server Requirements for Laravel
the failed to open stream: error usually occur when the OpenSSL PHP Extension not enabled.
PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
After enabling the required extension(s), do remember to restart your server, then run the following command:
composer update
Follow the steps below;
Download and install Composer.
Go inside the folder C:\xampp\htdocs>(if you are using xampp) or C:\wamp\www>(if you are using wamp) and open cmd/PoweShell & run the following commands:
composer global require "laravel/installer"
composer create-project laravel/laravel (after running this command a folder having name Laravel will be created there)
Now go inside Laravel folder and run php artisan serve command.
After executing the last cmd, it will show an URL: http://127.0.0.1:8000; access the URL in a browser, which should reflect the will see the default webpage of Laravel.
Download and install composer
Run composer global require "laravel/installer"
Open terminal inside C:\xampp\htdocs and run laravel new my_folder_name
You can just run
composer install
and it will process the required files to load the laravel in web browser
EDIT:
After seeing your comment, you should go to your laravel directory in your cmd.
cd C:\xampp\htdocs\laravelCMS
and run the command
composer install
Change your command to this:
composer create-project laravel/laravel cmsLaravel 5.2.*
This mean any sub version of laravel 5.2.
Check your index.php and Change the path as per your project directory
Register The Auto Loader
require __DIR__.'/cmsLaravel /vendor/autoload.php';
$app =require_once __DIR__.'/cmsLaravel /bootstrap/app.php';
composer create-project laravel/laravel 6.0
composer is a tool for dependency management in PHP
create-project is command to create a new laravel project
laravel/laravel is for the skeleton application you get when creating a new project. It provides a default structure that's recommended (you're not forced to use it). The repository contains default config files, controllers, routes, etc. As well as code responsible for bootstrapping the application.
Link Laravel/laravel
6.0 Version in laravel
just run your command line as admin
it worked for me
Please follow this step and try it
step 1
composer create-project laravel/laravel example-app
step 2
composer global require laravel/installer
laravel new example-app
step 3
cd example-app
php artisan serve
Else I will Recommend You To Go in to laravel offical page
Clik Here

Can't create projects with Composer on Windows 7

I'm trying to install Laravel with composer on Windows 7 and am running into an error. This is the command I'm running:
composer global require "laravel/installer=~1.1"
This is the error I get:
file_put_contents(C:\Users\myUser\AppData\Roaming\Composer/vendor/composer/installed.json): failed to open stream: No such file or directory
It's correct to say that the installed.json file does not exist, there's not even a composer folder inside the vendor folder. Not sure why that would be missing. I installed composer using the Windows installer.
Seems to be a composer related issue rather than laravel. I just tried installing yii and am getting a similar error running this:
composer create-project --prefer-dist yiisoft/yii2-app-basic MyApp
For this one, I get this after it successfully creates the folder and seems to load most files:
file_put_contents(C:\wwwroot\MyApp/vendor/composer/installed.json): failed to open stream: No such file or directory
Seems like the problem is that I never have a composer folder in my vendor folder.
UPDATE
I was able to get laravel to install globally by adding the COMPOSER_HOME environment variable. But I still run into a similar error when setting up a Laravel project after that
UPDATE 2
Some additional info, when I use the Windows Installer, composer gets installed in c:\ProgramData\ComposerSetup\bin. If I set the COMPOSER_HOME environment variable to this, laravel can get installed globally. But trying to install a project using the "laravel new MyApp" throws the following error:
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\wwwroot\MyApp\artisan on line 31
I suspect that's because I have PHP 5.4 and the latest version of laravel is 5.6 and above, but I want to install 5.0, which is 5.4 and above. I tried doing it using "composer create-project laravel/laravel MyApp 5.0 --prefer-dist" instead. I get the following error:
file_put_contents(c:\wwwroot\MyApp/vendor/composer/installed.json): failed to open stream: No such file or directory
Seems there's just something weird going on with paths that I can't quite figure out.
UPDATE 3
I've now uninstalled composer and re-installed it manually per the instructions provided on the composer site. I'm now trying to create a project using the following command from c:\wwwroot:
composer create-project laravel/laravel c:\wwwroot\MyApp --prefer-dist
It does manage to install some stuff, but seems I get this error before any package it tries to install:
Installing laravel/laravel (v5.1.4)
Loading from cache
Failed to download laravel/laravel from dist: RecursiveDirectoryIterator::__construct(C:\wwwroot/vendor/composer/,C:\wwwroot/vendor/composer/): The system cannot find the path specified. (code: 3)
Again, seems like it can't create a directory for vendor/composer for some reason. I tried running the same command, but from inside an empty c:\wwroot\MyApp folder, same result except the path in the error changes accordingly.
I found the following: https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows-
But I checked my registry and I have none of these entries. So still no clue.
It seems that your composer is not globally accessible. Try to add C:\Users{UserName}\AppData\Roaming\Composer\vendor\bin to your environment variable then restart your Shell or Command-Prompt so that updated Path variables is loaded. Now try to install laravel again.
Here is the detailed instruction:
Go to Control Panel > Systems ans Security > System > Advanced system settings then navigate to envirinment variables then scroll down and locate the PATH then add a semi colon (;) at the end of the PATH string. This means you are declaring a new variable. Then paste the C:\Users{UserName}\AppData\Roaming\Composer\vendor\bin after (;) you have added, restart the command prompt and try to install laravel again.
Uninstall composer and install it again, but this time do enable shell menu. Right click on the location (directory) where you want to create the project, select "use composer here", then "composer create-project laravel/laravel projectName --prefer-dist" should create your laravel project, default to latest version (5.1).
To specify your prefer version:
"composer create-project laravel/laravel 4.2 projectName --prefer-dist"
I will suggest you to install Homestead (http://blog.teamtreehouse.com/laravel-homestead-on-windows) and do all the heavylifting there.
You just need to do homestead ssh to actually connect to your machine and then perform all your operations.
Windows is pretty unpredictable in that kind of situations and in web development in general.

Laravel install in localhost

I am using windows 8 .I am using XAMPP.I installed XAMPP in D drive. My web root path is D:\php\htdocs. Location of php.exe file is D:\php\php. I would like to install Composer first then Laravel using composer. Could any one show me the whole process with step by step instruction ??
Add Php installation path to Environment Variable.
Cd to D:\xampp\php [Php Installation path]
Install composer using, php -r "readfile('https://getcomposer.org/installer');" | php
Create composer.bat file, using D:\xampp\php>echo #php "%~dp0composer.phar" %*>composer.bat
Check the installation using composer -V.
If it works fine, install laravel using the following command. composer create-project laravel/laravel myapp --prefer-dist
Download and run the Composer Windows Installer from here: https://getcomposer.org/download/
Go to web root directory D:\php\htdocs
Run composer create-project laravel/laravel myapp, this will install laravel project in D:\php\htdocs\myapp directory.

Resources