Installing Slim 3 using Composer - php

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/

Related

Not able to install symfony on windows

Hello I am trying to install symfony on Windows. I had follow the all require steps for it but it end up with below message.
[RuntimeException]
Symfony can't be installed because the downloaded package is corrupted.
To solve this issue, try executing this command again:
Symfony new demo 3.2.8
When i tried above command it says :
'symfony' is not recognized as an internal or external command,
operable program or batch file.
I have try to reinstall composer and Symfony package both but it does not resolve the issue. It stays the same issue again.
Please help me how can I install it on Windows.
You are required to make it run through PHP as its a script file.
This gets the installer (which it looks like you have already)
php -r "readfile('https://symfony.com/installer');" > symfony
Then php symfony new demo 3.2.8 (asuming if php is in path otherwise you have to specify the php.exe path too)
For the full details see http://symfony.com/doc/current/setup.html
Regards
forget about that installer use composer from command line
composer create-project symfony/framework-standard-edition my_project_name
BTW i don't know what server you are using (wamp/xamp etc), i recomending this
https://laragon.org/
it have composer and all tools that you need to start with symfony

'composer' is not recognized as an internal or external command in windows server

I am using windows server 2008 os. i download composer setup.exe and install to my PC . when I try composer install . I getting an error:
'composer' is not recognized as an internal or external command,
eg:-
c:\xampp\htdocs\shop>composer install
'composer' is not recognized as an internal or external command,
operable program or batch file.
My environment variable PATH is shown below:
C:\xampp\php\;C:\Users\Administrator\AppData\Roaming\Composer\vendor\bin
For anyone coming here from Google who are facing the same issue. I just managed to solve this issue after all the other "solutions" other people suggested didn't work.
I installed Composer properly and the Environment variable was set but it just wouldn't work.
In my case composer is installed in C:\ProgramData\ComposerSetup\bin and this is exactly what is in my PATH Environment variable. After messing around a bit trying to fix it I saw that under System variables under PATH there is something called PATHEXT I opened that and added ;.PHAR to the end of it. So it ended up like this:
And this is what my PATH is now:
I closed all file explorer windows and command prompts and started a new CMD and ran composer --version and it worked!
I hope this helps someone facing the same issue as me.
https://getcomposer.org/doc/00-intro.md#installation-windows
Close your current terminal and open a new one.
I had the same problem, I kept repeating the composer installation until it was resolved this way:
1) Download the composer installer (.exe) and put it on C:/XAMPP.
2) Run the installer by just clicking next till the end.
3) Open command-line (cmd) and cd to your project directory (C:/XAMPP/htdocs/myproject) and type composer and see if you have it installed.
4) It should work now, let's say you want to install a PHP framework from your project directory: cmd=>composer require slim/slim "^3.0".
I had the same problem .
In my case i used the command "php composer.phar " instead of "Composer " and it worked .
just paste " echo #php "%~dp0composer.phar" %*>composer.bat " This in your Terminal where you install composer and Boom you get the solution.
The solution is to use complete composer path instead of composer install
eg:- C:\ProgramData\ComposerSetup\bin\composer install" instead of "composer install
Better still, add "C:\ProgramData\ComposerSetup\bin\" to your environment variables, so that you can use "composer install".
If u can't find composer file than follow only 2 steps
1- Download composer file from [https://getcomposer.org/download/]<click on Composer-Setup.exe>
2- Install above file at your project root dir. and give second path is your php.exe file and finally solve this issue.
Simply use
like this
C:\jay\xampp\htdocs\zoho1>php composer.phar require zohocrm/php-sdk
You Just Don't need to worry about this if you have installed composer using Command-line installation than this problem will occurs.
So my suggestion is to download .exe file by visiting this link https://getcomposer.org/
And also after download using this link you don't need to use php composer.phar instead of composer only
I was facing the same issue in installing the composer command in cmd but when I closed all windows file explorers and again run this command "composer global require laravel/installer " from "**https://laravel.com/docs/8.x**". It just installed without any error
remove all your playings with composer path in path variable
go to https://getcomposer.org/doc/00-intro.md#using-the-installer
and find Composer-Setup.exe link to that exe.
I can solve this problem easily without do anything.
Suppose I'm going to create a project in my desktop and facing the problem which you have shown in the description. now follow the step.
Project folder on desktop
Step 1: go you your CMD(Command Prompt) of your Computer
step 2:Select the folder by command here like image (cd/desktop/example folder)
Step 3: After select the folder now write the command which you want to do like screenshot . you can see Im writing the command for laravel.
done, just easy step you can work anything from here and you can see downloading and being prepare for the project

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