Composer downloads project under php folder - php

My composer.phar file is under xampp/php folder. When I download cakephp through composer (by using command : php composer.phar create-project --prefer-dist cakephp/app myProject), it downloads the project folder (i.e. myProject folder) under : xampp/php/myProject. Although it should download the project under htdocs folder.
How to download a project through composer under htdocs folder?

Just indicate complete path to your project:
php composer.phar create-project --prefer-dist cakephp/app /path-to-htdocs/myProject
(disclaimer: I just tried with a global composer instalation, not throught a .phar, but it should work too)

Related

Laravel installed but nothing inside the folder

I ran following 3 sets of command in order to install laravel via command prompt :
1) composer
2) cd D:\xampp\htdocs\Laravel
3) composer create-project --prefer-dist laravel/laravel Laravel
It said that the download was successful , but when i opened the laravel folder , it is empty. So, i tried reinstalling it but it showed as below :
[InvalidArgumentException]
Project directory Laravel/ is not empty.
Any help on this ?
You should run:
composer dump-autoload
and if does not work you should:
re-install composer
and
composer create-project --prefer-dist laravel/laravel blog "5.8.*"
You should let composer installer create the folder for you.
Hence your updated list of commands would be:
CMD
cd D:\xampp\htdocs\
composer create-project --prefer-dist laravel/laravel demo_project
demo_project is the name of the folder/project name that would be created inside htdocs

Accidentally removed vendor folder in laravel project

I was working with a laravel project and, accidentally, removed vendor folder.
What should I do? Create a new project and copy it or download it anywhere else?
I had no additional composer dependencies installed.
Just run composer install after cding into the Laravel project's directory.
The Vendor folder is created by running composer install. It contains only the packages which you have asked composer to track in the composer.json file. If you have a composer.phar file in the root of your application run php composer.phar install.
https://getcomposer.org/doc/00-intro.md is probably your best source for additional information.

yii2 installation via composer - Could not open input file: composer.phar

I am trying to install the yii2 and after I installed the composer I tried to run composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
it says :
Could not open input file: composer.phar
Any suggestions ?
Make sure of composer work correctly.
php composer.phar -v
Try
php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
I know probably you've figured it out by now but still I want to help.
Make your composer.phar global so you can access it from anywhere. You can set path in environment variables or you can give direct path like below:
php C:\ProgramData\ComposerSetup\bin\composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
Note: I'm using Windows 8.1 and composer is installed in C directory.
First of all install composer in your system Like windows system. you can download composer from this url https://getcomposer.org/download/. after install composer you can go to C:\composer check files for composer.phar and composer.bat files then copy both files and goto C:\xampp\php paste both files here and restart xampp then after that you can install yii2

Laravel 5 installing error

Steps I've done:
I created a folder named 'laravel_5'.
open 'cmd' then typed 'cd D:\xampp\htdocs\laravel_5'.
re-enter 'D:' to change directory.
now I'm in the directory 'D:\xampp\htdocs\laravel_5'.
I input the command 'composer create-project laravel/laravel --prefer-dist' found in the laravel website.
Error occurred:
When you create new project using composer, it will automatically create project folder for you.
Go to D:\xampp\htdocs and change your composer command to this:
composer create-project laravel/laravel laravel_5 --prefer-dist
Or
If you still facing problem while using composer to create laravel project then simply go to github and clone the repo or download the zip and do composer update within your application directory.
https://github.com/laravel/laravel.git

Difference between require and install vs create-project in composer

I don't get how the create-project works in composer. Lets take Laravel as example.
I can install this PHP framework with the following command:
composer create-project laravel/laravel --prefer-dist
This command installs the framework for me leaving me with a few folder in the root of my dir:
app
bootstrap
public
vendor
Plus some files.
But when I simply use the following composer command:
composer require laravel/laravel --prefer-dist
composer install
Then this only installs the vendor folder. No other files and folders are downloaded by composer.
How come? What is so different? How does composer know what other files to get when I use the create-project laravel/laravel command and why do I only get the vendor folder when I do require laravel/laravel?
require will add a dependency to the composer.json file and load it into the vendor directory as you have correctly noticed.
create-project on the other hand will clone the dependency, i.e. use the dependency as a template for a new project. Take a look at the repository behind laravel/laravel: https://github.com/laravel/laravel

Categories