PHP Composer can't find composer.json file for my project - composer-php

I have successfully installed Composer in the root directory (that was the default choice) on my Linux/Apache server using their installation guide. It's all been very simple so far, except for one php.ini tweak I've had to make (detect_unicode = Off) but now I'm stuck.
I'm trying to install Ratchet using Composer, with the use of this guide:
http://socketo.me/docs/install
It says I need to "create a file called composer.json in your project folder". So I created that file (with the contents they gave on their page) using the cPanel file manager, in my application's root directory. However, when I run Composer using:
php composer.phar install
PuTTy gives the following error message:
Composer could not find a composer.json file in /root
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
But this doesn't seem to make sense, why would I place the JSON file in the server's root if the documentation says to place it in the project folder? What am I missing?

I just found on other topic that you can use :
php composer.phar --working-dir=/home/user/folder/ update

It looks like you're executing php composer.phar install in /root path.

Related

I can't install composer globally in my web host, how can I use the "composer" command?

I hosted my website on french host Gandi, with their simple hosting plan.
I cannot move anything in the /usr/local/bin directory since it is read-only, so I used to manage with composer.phar, which works well.
I recently used a library which requires the composer executable to be present (This library executes something like "composer require xxx" and there is no fallback to composer.phar).
Is there a way to make it work ?
What I have done so far :
Tried to install composer globally (Failed because of the read-only filesystem)
Tried to install composer globally for the current user (Failed because there was no ~/.local/bin directory, and also failed after creating the directory and restarting the instance)
Tried to move the file to any directory of the $PATH variable (Failed because all of these directories are read-only)
Tried to rename composer.phar to composer, and allowed it to be executable chmod +x composer (Failed because it only works with the command ./composer and not with composer)
Ok, I finally succeeded with the following steps:
renamed composer.phar to composer mv composer.phar composer
made this new file executable chmod +x composer
added the current path (corresponding to my website's root) to the system's $PATH variable export PATH=$PATH:$PWD
I'm not fully satisfied with this since this relies on a specific website's root folder, but hey, it works! I'll try to update this answer if I find a way to create a folder available for every website I'll host there.

Composer Installation Error on Windows 10: The installation directory is not writable

I try to install Composer (downloaded from https://getcomposer.org/download/) on Windows 10, but I get the following error message: The installation directory "C:\Users\BAB2~1\AppData\Local\Temp\is-5EP2P.tmp" is not writable.
Composer Installation Error
I have given full access to this directory, but it doesn't help. Could you please suggest any ways to solve this problem.
download https://getcomposer.org/composer.phar
drop composer.phar file into your PHP folder
make sure this PHP folder is on-path (so that you can call php everywhere)
if not, add the PHP folder to your environment PATH variable
run php composer.phar for testing. you should get Composer's help output
create a little batch file composer.bat to invoke composer easier:
C:\PHP> echo #php "%~dp0composer.phar" %*>composer.bat
This enables you to run composer in any PHP project folder.

Updating to the latest CakePHP 3.0 changes through Composer

I have installed CakePHP 3.0 using Composer on my PC (Ubuntu). I want to update the changes of CakePHP 3.0.
I have used the following link provided at CakePHP docs after changing the required package, but I am getting the below error in the terminal:
ubuntu#ubuntu:~$ php composer.phar update Composer could not find a
composer.json file in /home/ubuntu To initialize a project, please
create a composer.json file as described in the
http://getcomposer.org/ "Getting Started" section
Could you please provide a proper suggestion?
Note: I have the composer.json file in the project directory, so what should I do in that case?
you should issue that command in the project directory, where composer.phar and composer.json should be present. So cd /var/www/html/cake_project first.
You can set environment path to use composer in command line or you only need copy file composer.phar into your project folder and then cd into you project folder.
Finally, you run command php composer.phar update
Composer that will auto update CakePHP latest version.
http://rao5s.vn

Using Laravel "Warning:require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php): failed to open stream: No such

I am new to laravel, composer, and windows terminal. I am trying to setup laravel on my local host. I currently have wamp installed and I have used it before to create basic websites. However, I am now doing a bigger project that needs a framework so I decided to learn Laravel. I installed composer as indicated in the directions, but when i run the command
"C:\wamp\www>composer create-project laravel/laravel laravel"
i generate an error message that says
"[InvalidArgumentException] Project directory laravel/ is not empty."
When I open a browser and navigate to "localhost/laravel/public" I encounter the error message from the title of this thread:
"Warning:require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php): failed to open stream: No such
I have also added the appropriate environment variables from the composer instructions.
I am really lost at this point, and I have spent the past 4 hours trying to debug this.
I am running Windows 8 x64.
Edit:
I tried running composer install in C:\wamp\www and received an error message
Composer could not find the config file:
C:\ProgramData]ComposerSetup\bin Ti initialize a project, please
create a composer.json file as described in the
http://getcomposer.org/ "Getting Started" section "
The dependencies for your project are not installed. Just download composer from GetComposer.org and install it on your Windows Machine. Then navigate to your project root, you will see a composer.json file there. That file specifies all the dependencies of the project. Run composer update in that directory. Composer will then update or install all required dependencies and your application won't show the error then.
cd \wamp\www\yourproject
composer update
"C:\wamp\www>composer create-project laravel/laravel laravel"
"[InvalidArgumentException] Project directory laravel/ is not empty."
This means C:\wamp\www\laravel already existed when you attempted to run the command. Remove the folder, or change the create-project command to use a different folder name for your new project.
"Warning:require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php): failed to open stream: No such
You need to do a composer install from C:\wamp\www\laravel.
I figured it out! I was missing a folder called "vendor" and a file inside bootstrap called "compiled.php" Sorry for the inconvenience, and thank you for trying!
use the following command to get vendor folder in your project
composer install --no-scripts
i had the same problem but i just ran this command
composer install
to install all the dependencies

Laravel 4 Installation Problems on WAMP/Windows

First,I use wamp on my Window7.I open php-openssl,and I git pull the laravel from github.com,and then I put laravel on my d:/wamp/www/, I change the c:/windows/system32.But when I open the url
http://localhost/laravel/public
I see this question.
I am a newbie on laravel,and without install on Ubuntu.Where is my wrong, without no pear,or something else? Thank you!
You need to run composer install in a command prompt.
If you do not have composer, download the phar file from their website.
Place the file you just downloaded into the laravel directory.
Then, make sure that the absolute path to php.exe is added to your PATH environment variable.
Then, you can hold down shift, and right click anywhere inside the laravel directory, and open up a command prompt window. Then, run php composer.phar install. The process may take some time, depending on the speed of your internet connection.
Instead of using the above method, you can download the Composer installer for Windows, install it, and just run composer install.
Note that you only need to do this in order to put the Laravel components together. You do not need to run it on a live server.
Please consult the Laravel Docs for installation and other instructions: http://laravel.com/docs
Try This :
Installing Laravel 4 on WAMP
1. Enable OpenSSL
OpenSSL must be enabled in the PHP configuration.
Edit php.ini in your WAMP’s PHP folder, e.g.:
C:\wamp\bin\php\php5.4.12\
Note: This is not the php.ini in C:\wamp\bin\apache\Apache2.4.4\bin.
Find the following line and remove the semicolon save it:
;extension=php_openssl.dll changed to extension=php_openssl.dll
2. Install Composer
(i).Download the Composer Windows installer from getcomposer.org.
(ii). Run the installer.
(iii). When it asks for the location of php.exe, point it to the executable in your WAMP’s PHP folder, e.g.:
C:\wamp\bin\php\php5.4.12\
(iv). Finish the installation.
(v). Open a command-line interface (cmd) and type:
composer
It should return a list of options. If you get an error, restart your computer and try again.
Composer has now been installed and added to your PATH environment variable. This means you can run it from any directory using the command-line interface.
Now we need to install Composer. This is a dependency manager that will download the latest release of Laravel and specific versions of Laravel’s dependencies, such as Doctrine and Symfony.
3.Install Laravel
Now that Composer has been installed, Composer can download and install Laravel onto your system.
(i). Open a command-line interface (cmd).
(ii). Go to the directory in which you want to install Laravel. This is usually your development directory. In this tutorial, we’ll use C:\wamp\www\laravel
(iii). Instruct Composer to install Laravel into a project directory. we use project name myproject.
composer create-project laravel/laravel myproject --prefer-dist
Note: This will install Laravel in a subdirectory myproject of the current working directory.
Three type of installation to be completed
Now your project was running directory like
C:\wamp\www\laravel\myproject\public\
After completed put tick mark and increase the point....
Do php composer.phar dump-autoload or php artisan dump-autoload

Resources