bash: laravel: command not found - php

I am Using my own Machine Kali Linux 2.0 Debian x64 . Now, i have Installed Laravel in my directory structure like
/opt/lampp/htdocs/learning-larvel/
Inside the Learning-laravel folder i have Installed my Laravel files, and also i installed composer. So when i go to http://127.0.0.1/learning-laravel/public . I see a See a White Screen and in Between it is written "Laravel 5", which means the Laravel GUI Setup is fine.
Now, to create a new file for Laravel, when i open my Terminal and type
laravel new xyz
then it gives me a error which says bash: laravel: command not found
Now, how can i fix the error.. I have researched about it by setting PATH to bashrc. But i am not getting it fixed right. Additionally when i type in my command composer -version then also it says bash: composer: command not found but i have Installed composer on the folder learning-laravel itself.
I could also see files like composer.phar there in /opt/lampp/htdocs/learning-larvel/
Any help would be extremely thankful.

As the composer official getting started page points out:
There are in short, two ways to install Composer. Locally as part of
your project, or globally as a system wide executable.
if you wanna do composer -- or laravel -- in command line, you wanna install them globally.
Check out the following links:
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
https://laravel.com/docs/4.2#install-laravel

I encountered the same problem. Apparently, the composer exists in path ~/.config/composer/vendor/bin when running as super user. Therefore, replacing the paths which were described above by this, and it should work. Hope it helps.

Related

Symfony "no PHP binaries detected"

Ive been just starting to learn Symfony PHP framework, and Ive run into some problems with its configuration.
When trying to create a new project with command line like so:
symfony new --full my_project
I kept getting a simple error message:
no PHP binaries detected
and no files were created in the current folder. I searched on the net, and found out that Symfony apparently isnt able to find the location of my php.exe, despite it already being set in my system variables. And there was no information about how to properly configure this in Symfony.
How do I fix this error?
Turns out Symfony already contains functions to autodetect installed PHP versions from system variables. The command to fix the Symfony configuration is this:
symfony local:php:refresh
My next attempt to create a new project work fine after that.
Also, I suspect this error was the result of me installing PHP files after installing Symfony.
symfony local:php:refresh
doesn't always work. If your php is not in [/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /usr/games /usr/local/games /snap/bin] and a few other locations (check with symfony local:php:list -vvv) then symfony won't find it.
I compiled my own PHP from source and installed versions 7.4.20 and 8.0.7 in /home/username/php/7.4 and /home/username/php/8.0. If I want to use my PHP 8.0.7, then I have to make a symlink because updating the $PATH doesn't help.
sudo ln -s /home/username/php/8.0/bin/php /usr/local/bin/php
This works and symfony finds it.
Follow below steps:
Step 1: download & Install xampp in your system
Step 2: open the xampp folder.
find php folder and hit enter
Step 3: copy the path and paste in your system environment
Step 4 : run
php -v
you are good to go!

Installing Slim 3 using Composer

Hello. Please I am new to the php slim framework. I have tried all day to download and install slim 3 through composer but haven't been successful.
Am using a windows pc. I used command prompt and downloaded composer and installed composer to the desired directory. However, when i try installing slim 3, I get an error : "installation failed, reverting ./composer.json to its original content"
[Command Prompt Error Message][Command prompt error message]
you have to load the direction page of slim frame work using this link:
https://www.slimframework.com/docs/start/installation.html
and there will be a command like this - composer require slim/slim "^3.0"
instead of using this one you have to use this...
php composer.phar require slim/slim "^3.0"
and you will get slim installed
Kick-start Slim 3 projects using a skeleton!
With Composer installed, use the cmd line to access the C:\xampp\htdocs folder, then write this command:
$ php create-project slim/slim-skeleton [my-app-name]
Command will produce composer.json and composer.lock files along with a public/ folder that can all be committed to VCS (do not commit any other folders/dependencies).
Make sure you have high enough version of PHP, and PHP is in your PATH. To check this - print "php -v " in command line (you can pretty sure run up to PHP7).
Make sure you are in the right directory for your project.
Provide complete command line output, there could be things you didn't know to be important for a good answer.
After all, you can delete composer.json and composer.lock from the directory, and try again.
I use windows with XAMPP to run a virtual apache server.
After many similar issues, I downloaded git-bash and used it instead of the windows cmd.
give it a try, and see if that can resolve your issues.
https://git-scm.com/

error using composer to install cakePHP 3

i am lost...
i am trying to do it the right way and am following the Quick Start Guide for installing cakePHP 3 on my ubuntu machine.
Got composer installed. Directory is /var/www/cakephp
and am trying to issue:
php composer.phar create-project --prefer-dist cakephp/app mayapp
or
composer create-project --prefer-dist cakephp/app may app
then i am simply getting:
[InvalidArgumentException]
Could not find package cakephp/app with stability stable.
i do not have a clue what i am doing wrong. Any suggestions?
cakephp/app exists on https://packagist.org, and the command looks ok to me.
Which PHP version are you using? That package is only available with PHP 5.4.16 or later, so you must update if you want to use CakePHP.
However, it is a good idea to only use the same PHP version of your public hosting, using a newer version will lead to problems when deploying your code. If your webspace or public server does not have the latest PHP 5.6 running, ask for an update.
I got same issue. But, as previous answer, myapp does not exists on packagist.org, so, you must use laravel/laravel instead, and, after created, rename the new laravel folder to your desired name and move to htdocs (for xampp) or www (for wamp), then, and I do not know why, go to : localhost/laravel/public/
and replace laravel with the name you gave to your project folder instead the laravel one.
You will see Laravel 5 fonts will appear on screen.
That's means Laravel is running.
Hey Please try these steps.
Download XAMPP Server.
Install XAMPP server.
Go to ..\xampp\php\php.ini and open.
Add this line (extension=php_intl.dll) or if exist uncomment.
Download Composer setup from https://github.com/composer/windows-setup/releases/
Install composer and give php.exe file in path
Open cmd and check now php version using command php -v. if its showing php version its means its working.
Now open cmd and cd on xampp\htdocs folder & run command composer create-project --prefer-dist cakephp/app app_name
Finished folder created in htdocs.
Hope this is helpful for you.

Problems installing laravel with composer [duplicate]

This question already has answers here:
How to place the ~/.composer/vendor/bin directory in your PATH?
(22 answers)
Closed 6 years ago.
Problem: I'm wanting to explore laravel 5, and failing miserably at installing it. I'm using this guide: http://laravel.com/docs/5.0 and need someone to help me understand the instructions.
Background and What I've Tried
I'm running Mac OSX 10.10.2 (Yosemite) and MAMP.
So far, I've downloaded Composer to my home folder using terminal. There is just a composer.phar file sitting there.
When I run:
composer global require "laravel/installer=~1.1"
I get the message:
Changed current directory to /Users/MYUSERNAME/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
I assume that is ok because when I run the following in terminal, I get the composer logo and a list of options
~ MYUSERNAME$ composer
I'm not 100% sure what the following means, from the Laravel Docs:
"Make sure to place the ~/.composer/vendor/bin directory in your PATH so the
laravel executable can be located by your system."
Because I can't figure it out, the following steps throw errors, such as:
-bash: laravel: command not found
I've been going through a few forums, and it's suggested that I need to update my PHP.ini file - this seems more related to Composer install, and not specifically Laravel. Because composer is working, this seems to be a dead end.
Ideally, I want to install Laravel 5 to the directory
HomeFolder/sites/test
because Composer.phar is in my home folder, I think the command should be:
php composer laravel new sites/test
or just
composer laravel new sites/test
As mentioned, it just (correctly) throws errors.
Question:
If anyone can help solve my total user error, by explaining what "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable can be located by your system." means to a n00b, that'd be really appreciated.
Many thanks!
Laravel is a PHP framework (makes writing PHP applications easy)
Composer is a PHP package and dependency manager. (makes installing and updating third party code libraries easy)
When you run
$ composer global require "laravel/installer=~1.1"
You're using composer to install the laravel/installer=~1.1 package into composer's "global" project folder (usually ~/.composer). This is what installed the command line program named laravel.
The command line program named laravel is a shell script for installing the PHP framework (Also named Laravel).
Your "Unix Path" is a list of folders where a command line script will search for an executable. Usually is has folders like /usr/bin, /usr/local/bin, etc. This is why when you run ls, you're actually running /usr/bin/ls -- the shell knows to check each folder in the path for a location. You can view your current path by typing
$ echo $PATH
So, the problem is composer installed the laravel command line program to a folder that's not in your unix path. You need to add this folder to your unix path. You can do this by running the following (assuming you're using bash, which is OS X's default shell)
$ PATH=$PATH:~/.composer/vendor/bin
If you run that, you should be able to run the laravel command line program and continue your installation.
Most people add this to their .bash_profile or .bashrc files. The Unix Stack Exchange has a lot of good information if you're interested in learning how to do this.
You can add the directory to the PATH variable by editing /etc/paths.
Here's a tutorial on how to do that.
Just add a line with:
~/.composer/vendor/bin
Then the laravel new command should work fine
If everything fails you can still use the composer create-project command to make a new laravel instance:
composer create-project laravel/laravel sites/test --prefer-dist
I added C:\Users\Leon\AppData\Roaming\Composer\vendor\bin instead of ~/.composer/vendor/bin to the Path variable.
Here is instructions on changing the path variable on Windows 10:
http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path

Unable to update Laravel 4 with Composer (Update: bug?)

Today, I pulled down the laravel/laravel repository from Github. I then ran php composer.phar install (as I normally would on my system, with a command window in the project directory). However, when I ran php composer.phar update, I received this error:
Everything installed just fine, and Laravel works as it should.
Any ideas what could be causing this issue?
Edit 1
artisan exists in the root of the project, but it throws an exception when I attempt to run php artisan optimize:
Side Note 1
If I try the alternative method (quicker) of installing Laravel (php composer.phar create-project laravel/laravel), I get the following:
Edit 2
Upon installation, I also get the same error, where it claims it cannot find artisan. Therefore, the installation does not fully complete. I believe that it is stopping when it wants to compile classes (or something to that effect), and then write bootstrap/compiled.php. That file doesn't exist.
Here's the snap from the install:
Edit 3
It seems that Composer is looking for artisan in the drive root (C:\). Why is it doing this? Even if I specify -d on the update, it throws the error. (I picked this up from a hunch - simply copied artisan to the root of the drive and it found it - albeit, it obviously did not run...)
Solution Found:
Composer makes calls to php artisan <command> (as per the instruction in composer.json > scripts), but it does not see what directory it is running from (perhaps because it is an external command?).
So, I solved my initial problem by using an absolute path to artisan in composer.json.
Everything is working now. I just wish I knew how to get Composer to know that it is running from C:\LocalServer\lab\laravel, and not just C:\.
As i can see, your artisan file is missing. Can you post the exact steps on how you install it ?
Also, please follow http://laravel.com/docs/installation and http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
I had this problem today too. My laravel folder inside the vendor was deleted after composer update. I ran composer install again and problem resolved.

Categories