creating new laravel application on mac by laravel installer - bash

I have been strugling to create an application with laravel installer from terminal.
I have globally installed composer and laravel..
however i constantly get this error:
If you check at the bottom of the screenshot you can see -bash: new: command not found however laravel command is being executed perfectly. My osx version is 10.10.2. Macbook pro.
Any help will be appreciated.
Another question (bit out of the topic)
Is git inbuild in mac osx?
Cuz i hadn't installed it but it shows all of its commands.
Regards,
=======================
I created alias for composer and laravel in .bash_profile and .bashrc and it worked however now I'm getting this error :
Prajwols-MacBook-Pro:htdocs prajwol$ laravel new test
Crafting application...
Warning: ZipArchive::extractTo(): Invalid or unitialized Zip object in /Users/prajwol/.composer/vendor/laravel/installer/src/NewCommand.php on line 99
Warning: ZipArchive::close(): Invalid or unitialized Zip object in /Users/prajwol/.composer/vendor/laravel/installer/src/NewCommand.php on line 101
Application ready! Build something amazing.
Result : An empty folder is created called test in destination folder.

The command needs a project name: laravel new <NAME>. Like laravel new blog. This will create a new laravel project in a new blog directory in the current path.

$ brew tap homebrew/homebrew-php
$ brew install php72
Install composer
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Install Laravel
$ composer global require "laravel/installer"
$ composer global -vvv require "laravel/installer"
now run command
composer

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 ^_^

Laravel package installation on live server

How to install package in laravel on live server, whenever I run "command composer require monolog/monolog". It gives error Could not open input file: /home/root/composer.phar
First of all, you should not run composer require on live server. You should only run composer install so you should require it locally, test if everything is working fine and then on live server just install library that is tested in your application.
About error:
Could not open input file: /home/root/composer.phar
make sure this file really exists (if not you can download it from Composer site) and make sure it has correct permissions (it should have execute permission) - use chmod +x composer.phar to make it executable
Please try like this.
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
$ php composer.phar update monolog/monolog
You can install package without any problem.

Getting Error in installation of yii2 advance template

I'm new to Yii2, I'm trying to install yii2 application advanced template.
I did follow these steps:
1 - Download yii2-app-advanced zip file from https://github.com/yiisoft/yii2-app-advanced
Follow GETTING STARTED guide:
My vendor directory Show Empty.
Please help, thanks in advance
Installing via Composer
If you do not already have Composer installed, you may do so by following the instructions at getcomposer.org. On Linux and Mac OS X, you'll run the following commands:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
On Windows, you'll download and run Composer-Setup.exe.
Please refer to the Composer Documentation if you encounter any problems or want to learn more about Composer usage.
If you had Composer already installed before, make sure you use an up to date version. You can update Composer by running composer self-update.
With Composer installed, you can install Yii by running the following commands under a Web-accessible folder:
composer global require "fxp/composer-asset-plugin:~1.0.3"
composer create-project --prefer-dist yiisoft/yii2-app-advanced basic
The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs Yii in a directory named basic. You can choose a different directory name if you want.
Note: During the installation Composer may ask for your Github login credentials. This is normal because Composer needs to get enough API rate-limit to retrieve the dependent package information from Github. For more details, please refer to the Composer documentation.
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced basic
Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %>composer.bat*
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate
Refrence
use composer cos you need composer in future too!
and after unzip the advance project in www or htdocs you should navigate to your project with cmd or terminal and type yii migrate after that again type composer update

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.

Unable to Install Laravel 4.1 on Maverics OS X

I am trying to install laravel 4.1 on Maverics OS X using the document provided on the laravel site.
I am trying only two methods provided: via laravel installer & via composer. The third option is not preferred because I will only be able to apply these two methods on my production server.
I get following errors
a) Using via laravel Installer: I issue following commands (assuming I have downloaded in downloads dir)
downloads$ mv laravel.phar /usr/local/bin
cd ~/rohinigeeks
rohinigeeks$ sudo laravel rohinigeeks
ERROR:
sudo: laravel: command not found
b) Using Via Composer. I issue following commands
composer create-project laravel/laravel rohinigeeks --prefer-dist
ERROR:
[ErrorException]
unlink(/Users/apple/.composer/cache/files/symfony/security/ef511d47c94ad92e
37112b43efcbf7da8696a803.zip): Permission denied
Your help will be appreciated.
-AK
You installed laravel.phar in /usr/local/bin, so use that as the command name. Or rename it to /usr/local/bin/laravel:
mv laravel.phar /usr/local/bin/laravel
Also make sure it's executable:
chmod a+x /usr/local/bin/laravel
And if you're using tcsh (is this still the OSX default?), make sure to use rehash.

Resources