Composer can't find composer.json - php

When I download any Laravel project and run composer install it says to me:
Composer could not find a composer.json file in C:\Users\gbl\My
Documents\vertrigoserv\www\
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
It doesnt work with any Laravel project i try to run. There is composer.json in all the projects, but composer cant find them.
I am using Windows 10. Tried to reinstall composer few times and nothing happens.

you might want to try installing composer with-in your project directory.
that will create composer.json in your project folder which will enable you to add whichever packages that you wish to add to this composer.json and update it.
also make sure you have added php and composer in your PATH variable
give this a try and let me know if it solved your issue.

Related

composer install recognizing updated composer.json file

I am familiar with the concept that, when composer.lock file is present, composer install command runs the packages from this file.
So when I add (manually put a vendor/pkg list) to "require" in composer.json, and run command install then only those packages locked in composer.lock files get installed.
But this understanding of mine got conflicted, when I found composer.lock file being git-ignored by my senior developers.
When any update on composer.json file is pushed to deployment server, command install is being run and it seems to "install" the updated packages.
What got me confusing is, since there's no mention of that newly added package in the composer.lock file in the deployment server, how is it being installed?
I tried the same on my local:
first added vendor/pkg in require of composer.json.
tried running command install.
And got this warning instead:
warning: the lock file is not up to date with the latest changes....
nothing to install or update.
So my question is :
why two different behaviors are being shown?
How are the newly added packages in .json and not in .lock are being installed in the deployment server and not in local?
I have been researching on this for a while, and its bugging me.
Maybe I am getting it wrong. Anyone there to clear this out?
There are a few options:
Add vendors with composer require vendor/pkg
Add in composer.json as you did, but then run composer update vendor/pkg (Running composer update without the package name will update all of them)

Laravel composer.json fully istallation

Is there any way to install laravel from only composer.json file by using
composer install
command. If i just copy composer.json from existing project it creates only vendor directory, but not app, database, etc.
I just want to load all laravel core files, project file structure and my custom package by using install command of composer.
Can someone help me with this?
You can install laravel with the command composer create-project --prefer-dist laravel/laravel <project_name> if you only want to use composer, this command is mandatory since it creates the directories you want.
See the documentation
I don't think you can.
Create a new laravel project or clone an old project from git. Then replace/update the composer.json, then run composer update, if its a new project or composer install, if you cloned a repo
I didn't find solution for this, maybe it's impossible.
So, i just create my package and manually copy my custom composer.json to project.

Facing issue installing pug-php/pug-symfony on Symfony 2.8.26

I am facing an issue while installing pug-php/pug-symfony in Symfony 2.8.
I started with a fresh symfony installation and executed
composer require pug-php/pug-symfony
All the dependencies were fetched and downloaded and tyhe composer.json also got updated, however in the step of autoloader.php generation, it comes up with this error. (below image)
autoload.php issue when installing pug on symfony
To debug the issue, i tried executing
composer dump-autoload -o
and the same error pops up again.
Next, I tried something cheeky and created a new blank autoload.php file in the Symfony project directory root, and again executed composer update and composer dump-autoload, however, this time am getting this,
composer update issue (2)
Please help.
Your path is wrong currently it is stating that there is no autoload.php file in the directory C:\xampp\htdocs\demoSymfony\autoload.php. There should be a vendor directory where the autoload.php file is found. Can you update your question with the current Repository structure/hierarchy? That will probably give us more info to help you.
Straight from their docs: For libraries that specify autoload information, Composer generates a vendor/autoload.php file. You can simply include this file and start using the classes that those libraries provide without any extra work
https://getcomposer.org/doc/01-basic-usage.md#autoloading
We have solved this issue, you should now be able to install it with no such problem by following the README install process:
https://github.com/pug-php/pug-symfony#pug-symfony

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.

Installing Yii2: Invalid Parameter – yii\base\InvalidParamException

I'm installing Yii2 in the way that shows the Getting Started tutorial:
composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
When I try to access localhost/YiiTutorial/basic/web I get this error:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: C:\wamp\www\YiiTutorial\basic\vendor\bower/jquery/dist
In the tutorial says that is nothing to edit... it should work right out of the box... what I'm missing?
If I download the package and place it in the same folder, it works perfect, but I want to install it from composer!
Inside vendor/bower folder it's another one called bower-asset.
Copy this folder content (some other folders named bootstrap, jquery, etc...) and move them to vender/bower.
it a recent bug. update your fxp plugin to latest version (1.1.1) and clear composer's cache and try :
composer self-update
composer global update
composer update
Mainly if not issue regarding to vendor installation so please give permission to your /assets and /runtime folers of your projects and try to run again.
In your vendor folder you should rename bower-asset to bower .
OR you can use the following
make sure that you have the following in your composer.json:
composer.json
Other ways
I have encountered this kind of problem lately, the issue is in your composer it missing the asset-plugins which allows managing bower and npm package dependencies through Composer. Just run this command, you only need to run this command once for all. You can read the yii2 docs. Yii2 Installation
composer global require "fxp/composer-asset-plugin:^1.2.0"

Categories