Laravel - Unable to open composer.phar file - php

Hey just started working on laravel. First day for me. Not much idea. Step by step following the steps from documentation given by https://www.laravel.com
After installing composer on my desktop at root folder. As soon, i opened composer.phar, it showed this error -> there is a problem opening the file "/root/composer.phar"
I followed steps given in https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx .
apt-get install curl
apt-get install php5-cli
curl-sS https://getcomposer.org/installer | php
php composer.phar
Is there any problem ? Please help me........

For installing composer try follow this
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
Setting up Laravel
Run only composer and see if composer is installed.
If yes then let's install laravel installer to quickly install laravel. Run this command from your command line composer global require "laravel/installer=~1.1"
Now if you are using zsh then add this line to user home directories .zshrc file export PATH="~/.composer/vendor/bin:$PATH"
Else add this lines to .bashrc file export PATH="~/.composer/vendor/bin:$PATH"
Now you can run laravel new blog and a new laravel installation will be downloaded.
Now run php artisan serve from that directory to serve your laravel
See http://laravel.com/docs/5.1/#installation for more details
Tips: You can create a separate file and include it to your
.zshrc or .bashrc

Related

How to install Composer on macOS?

I was trying to install the Composer on my macOS version: high sierra--> 10.13.4
but after using the command:
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
It created some files and directory but it didn't download the composer.
My terminal displayed following error:
No log handling enabled - using stderr logging
Created directory: /var/db/net-snmp
Created directory: /var/db/net-snmp/mib_indexes`
How can I resolve this problem?
OLD Answer (The Ruby Homebrew installer is now deprecated and has been rewritten in
Bash.):
First install Brew on your MAC:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
NEW Answer:
First install Brew on your MAC:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install PHP:
brew update
brew install php
brew install composer
To test installation, run:
$ composer -V
Install Brew in Mac Terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Composer
brew install composer
Check Composer
composer -V
Install download the composer using the following curl command in the
terminal:
curl -sS https://getcomposer.org/installer | php
After the command, you will have composer.phar file in the current
directory and the composer command is available as:
php composer.phar [composer commnad]
In order to make composer available globally, you have to move the
recently downloaded composer.phar to local user’s bin folder as follow:
go to /usr/local/bin folder . You can click Shift + Command + G to open
the dialog to go to folder.
move the recently downloaded composer.phar in the usr/local/bin folder
create a alias using command alias composer="php
/usr/local/bin/composer.phar"
Now, you can access the composer from the terminal simply using the
composer command. Thats it.

Laravel PHPUnit with bitbucket-pipelines.yml file. Vendor related files not found issue

I have laravel 5.3 project on bitbucket. I have all folders integrated with bitbucket except auto generated folders like Vendor folder. And I am trying to run Unit test with bitbucket-pipelines.yml.
But It is showing error
"PDOException: SQLSTATE[HY000] [2002] No such file or directory"
on vendor files like /opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php as I don't have vendor folder on bitbucket.
Is there any way to run PHPunit without vendor folder?
I have also tries composer update command before PHPUnit in .yml file.
Thanks
I got solution. We simply do this by creating docker image. I have done this by writing these commands in .yml file
apt-get update && apt-get install -y unzip
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
composer -V
php -r "file_exists('.env') || copy('.env.example', '.env');"
composer install
php artisan key:generate
You can add composer install -o --no-suggest to your bitbucket-pipelines.yml, so that it will get all the dependencies before run unit tests.

Installing laravel ( sh: 1: composer: not found) error

I've been trying to install laravel on Ubuntu 14.04. I finished all the steps, but when try to
laravel new mySite
the following message is deployed:
Crafting application...
sh: 1: composer: not found
Application ready! Build something amazing.
It's looks like some trouble with composer, but I don't know why. Composer seems to work, so, what is wrong? Thank you!
I got the same error.
I fixed it with simple symlink.
locate it. Run: # whereis composer
composer: /usr/local/bin/composer.phar
then create link: # sudo ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
Thats it. All works.
If you run composer on shell, does it run? otherwise run:
sudo apt-get install curl php5-cli git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Then try again, maybe you could try the composer installation syntax:
composer create-project --prefer-dist laravel/laravel blog
To be sure composer is updated to the latest version and nothing is in cache run:
composer self-update
composer clear-cache
I still can't use laravel new, but I found what was happening with composer.
Laravel 5.3 needs php5.6 or higher, otherwise will run an older laravel version. I upgrade to php5.6 with this steps: https://www.dev-metal.com/install-setup-php-5-6-ubuntu-14-04-lts/
then run
composer create-project laravel/laravel ProjectName
and it's done!

How to install Laravel 5.2

I am installing the Laravel framework in directory /var/html/www, using command
php composer.phar global require "laravel/installer"
It changes installation directory automatically, shown message is:
Changed current directory to /home/.composer
What is the reason? Do I need to add any other command?
This is because you installed the Laravel installer with global, which makes it globally available for all projects and installs it to /home/.composer.
This should be all right because it is only Laravel's installer and not a Laravel project which should be created in a later step (see below) and this should be installed in your /var/html/www then.
Run the following command in your /var/html/www to create a new project (doesn't need Laravel installer):
composer create-project --prefer-dist laravel/laravel YourProjectName 5.2
or use the Laravel installer
laravel new YourProjectName
For more info how to install Laravel see the documentation here.
Let use
composer create-project --prefer-dist laravel/laravel project_name "5.2.*"
1) change the permission of your directory to allow CRUD.
Open Terminal and paste this command
sudo chmod -R o+rw /var/html/www
2) update the package manager cache by running:
sudo apt-get update
3) cd to your directory to check if composer json does exist
cd /var/html/www
and type
composer
4) To install composer in your directory run
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
5) To test if it's installed run
composer
6) Now install laravel 5.2 in your directory (/var/html/www)
composer create-project laravel/laravel ProjectName 5.2 --prefer-dist

How to install cakephp 3.1.6 on LAMP

I want to install cakephp3 on ubuntu14.0.4 in lamp. I put cakephp3 folder in /var/www/ path. When I enter localhost/cakephp3/in browser, nothing is shown.
What should I do?
Follow this,
http://book.cakephp.org/3.0/en/installation.html#installing-cakephp
open terminal,
Create a folder in var/www/html
mkdir /var/www/html/cakephp3
Navigate to this folder and install composer there
cd /var/www/html/cakephp3
curl -s https://getcomposer.org/installer | php
Install php in the same folder
php composer.phar create-project --prefer-dist cakephp/app
You must get your cakephp application now.
My error.log :
127.0.0.1:59267] PHP Fatal error: You must enable the intl extension to use CakePHP. in /var/www/html/cakephp-3-1-6/config/bootstrap.php on line 38
So
install "intl" plugin:
sudo apt-get install php5-intl
and restart apache:
sudo service apache2 restart
And Try again in browser: localhost/cakephp3/
It worked for me.

Categories