Laravel Installer method - laravel

Normally I do install Laravel 5.1 by following this command regarding to documentation:
composer create-project laravel/laravel --prefer-dist
It works fine.
But I read in the documentation under "Via Laravel Installer" also it is possible to install via Laravel Installer, which is much faster than installing via Composer:
laravel new blog
But to use this method I need to run following command once:
composer global require "laravel/installer=~1.1"
When I do run it I get following errors many times
Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks
is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks()
instead in
phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Package/Version/VersionParser.php:226
after many line of same error ./composer.json has been updated appears and it continues with the same line of errors, it ends with following
Loading composer repositories with package information Updating
dependencies (including require-dev) Nothing to install or update
Generating autoload files
What is wrong with it? Any idea or solution.
My environment: Windows 10, GitBash and cmder console.
Update of composer, I did ran composer self-update also
Snapshot of console
EDIT:
Note, I can confirm after solving the issue that the installation via Laravel Installer method is faster than composer.

The Composer Assets Plugin you've installed locally is using a deprecated method of Composer. The plugin is already fixed, so run composer global update to get the latest versions with the bug fix. After it, you should be able to run the command succesfully.
If this doesn't work (as you might get the same error running the previous command), try removing the global vendor directory. When running any global Composer command, it outputs something like "Changed current directory to XXX". Remove the XXX/vendor directory and then try running the command.

In addition to #WouterJ answer.
Worst case if the steps provided by #WouterJ did not work, you could manage to uninstall and reinstall composer for windows.
When done, run composer global update to be sure to get latest updates, if there was.
Then run composer global require "laravel/installer=~1.1" and it should works.
Remember to update your windows environment path C:\Users\UserName\AppData\Roaming\Composer\vendor\bin

Related

How to install composer globally for laravel app in windows?

I have a question related to composer and laravel. My question is whenever I install the fresh laravel app using command :
composer create-project laravel/laravel blog
Inside my C://xampp/htdocs/ directory and then change path to C://xampp/htdocs/blog/, here I am unable to run the composer command but I had already installed composer from its official website globally in C://xampp/htdocs/ directory. So is there any way to use composer command globally whenever I install fresh laravel app, so that I don't want to install composer in the laravel app directory everytime.
Now I guess they provide direct setting up global installation,
Check here
I did it like this a lot earlier,
Change to the path (or you can add that directory to your path later), and run the installer as mentioned on composer download site to download composer.phar.
Create a new composer.bat file alongside composer.phar.
Using cmd.exe:
run
echo #php "%~dp0composer.phar" %*>composer.bat
Then set it to path environment variable(see this)
Test with a new terminal:
composer -V
Will return
Composer version 1.10.6 2020-05-06 10:28:10
go to composer website and download the exe file, you should have it gloablly if you install it that way.
Good luck ^_^

Failed to initialize global composer: mac /Sites

Trying to view a local website:
"Uncaught Error: Class 'ComposerAutoloaderInite0e6765..etc' not found in /Users/{ username }/Sites/{ sitename }/htdocs/vendor/twig-autoload.php".
So on into Terminal to do composer dump-autoload. (It worked the first time I did it).
I now get this message:
"The 'git' command requires command line developer tools. Would you like to install the tools now?" (It asks for Xcode)
I click No.
Terminal tells me the file command has been run OK, but no...
Repeating the dump autoload with -vvv reveals the truth:
Failed to initialize global composer: Composer could not find the config file: /Users/{ username }/.composer/composer.json
Searching about, the only things I've found on the composer error seem to be related to Lavarel.
info:
Composer is installed in /Sites/{ sitename }/vendor/
Composer version: 1.10.6
So what I'd like to understand:
Why is composer trying to initialise a 'global composer'? Does it think the locally installed one is global, or could there be another Composer it's trying to default to?
How do I tell composer where the json file is?
What should I do about the xCode message, if anything?
I've reinstalled composer (and Twig - the only package I'm using - seems overkill for one package, but trying out alternatives didn't end well).
The site is now back running (locally).
Still have the issue of xCode request from Terminal, but that's for another question.
So the answer seems to be: Reinstall composer and packages.

Differences between install via artisan and composer

I found that web.config is included when I install Laravel with:
composer create-project --prefer-dist laravel/laravel blog
but not when I install Laravel using the Laravel installer, with:
laravel new blog
(as per https://laravel.com/docs/5.8/installation)
I've subsequently found a few other differences e.g. devDependencies versions in package.json, some config settings in broadcasting.php, cache.php, database.php.
Can anyone explain to me what is responsible for this difference? Is one install method 'better' than the other?
Thanks
Chris
The difference between both commands is that the composer command uses packagist to get the latest package from GitHub the first time or a cached version, while laravel new blog downloads a zip file from the Laravel server which has the latest version and uses that. Both commands run the so called 'after install' scripts, creating an environment file and setting the application key.
When you don't want a cached version but a new one using composer, run composer clear-cache first, to delete the local cache composer creates.
If you want to see the difference for yourself, compare the composer.json of the base Laravel project (https://www.github.com/laravel/laravel) and the NewCommand.php file in the src directory of the Laravel installer (https://www.github.com/laravel/installer)
Edit
After running both commands, the only difference I could really find was the order in which some things are done, but both generate a working system. Fun thing I noticed is that laravel new project comes with a yarn.lock file, but without a readme.md and composer composer create-project vice versa.

Cannot install Laravel correctly

I followed all the instruction by installing composer and then Laravel. Also I did everything what was shown in laracast series for installing Laravel and composer.
BUT I have some problems and I cannot solve them:
I don't have Vendor folder in my Laravel app folder
I cannot launch command 'composer artisan' as it says that
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "artisan" is not defined"
"php artisan" also doesn't work
All the answer in the web I have already tried to resolve my problems but nothing worked for me
Please, tell me, how can I install Laravel correctly and use it without errors
Run composer install or composer update. This will create the vendor folder and download all the dependent modules as mentioned in the composer.json
I want to add some more details which are asked but not clearly answered.
You did not install the composer dependencies. Try composer install.
It is not composer artisan. If you execute that command, you say hey composer! run your artisan command. And it says "Command "artisan" is not defined."
It is php artisan. But if you don't run composer install, php artisan will not work either. Because you are missing Symfony Console Component in your project (not the one used by composer) as well as a complete Laravel installation. Both will also be installed by the composer install command.
Well. I've solved my problem. As I mentioned before I had tried all the answer in the web but nothing had helped me. So then I just deleted my laravel project and ran this command
sudo apt-get upgrade
After some time packages were upgraded and I created new Laravel project. And Laravel started working perfectly! So in any incomprehensible situation do apt-get upgrade :))

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.

Resources