I'm trying to add FirePHP to my Zend Framework 2 project using composer, but I get errors.
My OS is a Windows 7.
I tried following ways to make it working:
I added following code to composer.json file:
"repositories": [{
"type": "vcs",
"url": "https://github.com/RobLoach/firephp-core"
}],
"require": {
"firephp/firephp-core": "dev-master" // Tried also: "firephp/firephp-core": "*"
}
Here is a error I got:
[RuntimeException]
Failed to clone http://github.com/RobLoach/firephp-core.git, git was not found, check that it is installed and in your PATH env.
I tried add to composer.json following code, which I found in firephp pull request. :
"require": {
"firephp/firephp-core": "*"
}
But it gives me same error I have posted above.
Composer is totally new for me. I couldn't find any helpful tutorial for it, so I'm not sure how does it work yet, but I'm doing my best to get familiar with it.
I hope someone can tell me what I'm doing wrong.
Thanks.
EDIT:
I got it working thanks to #Seldaek help, but it removed my Zend library folder.
Here is log from cmd:
E:\xampp\htdocs\ZendSkeleton>php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing firephp/firephp-core (dev-master f60753a)
Cloning f60753a8dd7817e4da6bc73e0e717387a9a0866a
- Removing zendframework/zendframework (2.0.5)
Writing lock file
Generating autoload files
Is there any way to stop removing Zend folder?
Here is my full composer.json file:
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*"
},
"require": {
"firephp/firephp-core": "dev-master"
},
"config": {
"bin-dir": "E:/xampp/htdocs/ZendSkeleton/"
}
}
The problem is the package only has a dev-master version available, and those are by default installed with git. If you don't have git available in your PATH you can run composer with --prefer-dist which will force it to install from zip archives instead of via git. Something like composer update --prefer-dist should work out.
The better fix though would be to make sure that the git executable is accessible in your PATH environment variable. If you have no idea what I'm asking, maybe another option is to run composer from the "Git Bash" shell instead of cmd.exe.
Related
I use the command composer require otra/otra:dev-develop --no-update --no-cache && composer update --no-autoloader to install my own framework.
I have put this section in my composer.json from my framework :
"scripts": {
"pre-install-cmd": "#composer config bin-dir bin/"
}
But Composer does not run it. Is this normal, does Composer consider this as a dependency and not the root package so it does not allow my script to run?
If this is the case, how can I have the same behaviour?
I want to :
have my binary in the bin folder, not vendor/bin without having to ask the user to do a symlink manually (or another solution)
copy a web folder from my framework to the root of the project.
Edit : with create-project command
If I type composer create-project otra/otra:dev-develop crashtest --remove-vcs, I get this composer.json :
{
"name": "otra/otra",
"type": "library",
"description": "The OTRA PHP framework",
"keywords": ["framework"],
"homepage": "https://github.com/lperamo/otra",
"license": "X11",
"authors": [
{
"name": "Lionel Péramo",
"email": "contact#lionel-peramo.com",
"homepage": "https://wexample.com"
}
],
"bin" : ["otra.php"],
"config": {
"bin-dir" : "bin/",
"sort-packages": true
},
"require": {
"ext-mbstring": "*",
"php": ">=7.4.0",
"symfony/yaml": "^4.0"
},
"require-dev": {
"ext-pdo": "*",
"ext-pdo_mysql": "*"
},
"scripts": {
"pre-install-cmd": "#composer config bin-dir bin/"
}
}
which is exactly the same as my framework so I cannot update it via Composer. I could with git if I do not use --remove-vcs but it is not the goal.
The output of the composer command is :
Installing otra/otra (dev-develop ab37237565155dab11812a7b2982d30ee240f051)
Installing otra/otra (dev-develop ab37237): Cloning ab37237565 from cache
Created project in crashtest
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Only scripts defined in the project's proper composer.json file are executed.
Scripts from required and installed packages are never executed because it would be terrible safety risk.
This is summarily explained in the docs:
Only scripts defined in the root package's composer.json are executed. If a dependency of the root package specifies its own scripts, Composer does not execute those additional scripts.
If your package users need to perform additional steps to use your package or library, explain those steps in your package documentation, and or provide scripts that they can execute manually and will perform those steps for them.
If your package is a "framework", as opposed to a library, what you could do is take advantage of composers create-project command.
That would require you to setup are repository with the default structure for a project, which would in turn depend on your package.
That's the way it's done with Symfony's Skeleton, for example.
With this kind of setup, you can create custom installation scripts and activate them with the post-create-project-cmd, and do some some extra setup steps, even interactive one, with something like this. (docs)
Be mindful that this script would only run when the package is installed using create-project, and never when using require.
Nobody mentioned, this can be achieved by creating a composer plugin and defining event handler for event post-package-install
I am learning on how to upload a package on packagist.org. I created a github repository for testing with composer.json file -
https://github.com/perials/check
and a composer package using this github repository - https://packagist.org/packages/perials/check
When I try to install this package using composer require perials/check I get below error
[InvalidArgumentException]
Could not find a version of package perials/check matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.
From what I read in other related questions on SO this error occurs if there are no stable releases of github branch. But thing is that I already have some releases.
I also tried composer require perials/check:dev-master and composer require perials/check:7.1.0 but then I get below error
[InvalidArgumentException]
Could not find package perials/check.
Did you mean this?
perials/check
It was an issue with Singapore mirror for the packagist metadata. Now it should be resolved. https://github.com/composer/composer/issues/8347#issuecomment-537176755
If still not solve your issue please add "minimum-stability": "dev" in your composer.json
{
"name": "perials/check",
"description": "Package for testing packagist",
"license": "MIT",
"authors": [
{
"name": "Perials",
"email": "info#perials.com"
}
],
"autoload": {
"psr-4": {"Abc\\": "src/xyz"}
},
"require": {},
"minimum-stability": "dev"
}
I am also learning how to create packages and have the same problem, but in my case I created a v1.0.0 tag for my package and that solves the problem.
You can accept no stable version packages. See composer in docs (https://getcomposer.org/doc/04-schema.md#package-links).
Paste piece here for convinience:
You can apply them to a constraint, or apply them to an empty constraint if you want to allow unstable packages of a dependency for example.
composer.json:
{
"require": {
"monolog/monolog": "1.0.*#beta",
"acme/foo": "#dev"
}
}
In your case you would do:
{
"require": {
"perials/check": "7.1.0#dev"
}
}
and then run rm composer.lock; composer install.
I've developed a custom laravel package and put it on GitHub. I put it in composer.json (code below) and it installs fine.
I have no version info on it yet, since it is still in development. When I make changes to my package (in a separate directory), I commit and push the changes up to the GitHub repo.
When I run 'composer update', I get "nothing to install or update". If I delete the package from my vendors directory and update, then my package IS installed from the GitHub repo, with the latest changes.
But I would like to be able to pull/force the latest changes from the repo without deleting it first from my vendors directory, since I have other dependencies on that package, and if I delete it, I get errors from artisan clear-compiled that classes are not defined (since they are defined in my deleted vendor package...)
The relevant portion of my top-level composer.json is:
"repositories": [{
"type": "package",
"package": {
"name": "myrepo/MyExtension",
"version": "dev-master",
"source": {
"url": "https://github.com/myrepo/MyExtension.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-4": {
"MyExtension\\": "src/Extensions/"
}
}
}
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"myrepo/MyExtension": "dev-master"
},
You have created all meta data about your package yourself, likely making Composer think that the data didn't change.
The easier, and probably working, way would be to simply point to the repository URL and let Composer query the meta data from the composer.json file contained in the repository:
"repositories": [{
"type": "vcs",
"url": "https://github.com/myrepo/MyExtension.git"
}]
For it to update your changes you need to version your package but as you said earlier you are not versioning your packages so for it to update your changes you can go to composer.lock to remove your package entry or to use composer to remove the package and install it again. eg
// composer remove vendor/package && composer require vendor/package
composer remove zizaco/entrust && composer require zizaco/entrust
I'm trying to install composer in terminal by entering this command:
php composer.phar install
it starts to install required packages but I'm getting this error type:
[RuntimeException]
Could not scan for classes inside "app/commands" which does not appear to be a file nor a folder
How can I overcome this issue?
Usually this happens when you have some corrupted files or any composer update has crashed or interrupted.
To solve, just delete the vendor folders and run
composer install
When you install Laravel it creates a
app/commands
folder. Looks like it's not there. Just create it or remove from composer.json:
"classmap": [
"app/commands", /// <--- this line
],
And run
composer update
artisan dump-autoload
The last one is similar to composer dump-autoload, but it does some Laravel stuff too.
If you don't have any commands you don't really need it. If you plan to create artisan commands, create that folder and it should work.
I had the same problem. In my case, I noticed that there was no app/commands folder in my laravel install. I created the commands folder and composer dump-autoload was working again!
You should be able to solve this issue by simply running:
rm -rf vendor/autoload.php vendor/autoload_runtime.php vendor/composer && composer install
This cleans up the corrupted files without having to remove the entire vendor folder or cleaning up the global cache.
As others have mentioned, this usually happens if you interrupt a running Composer (e.g., Ctrl+C during composer update). But it does not corrupt all of the files, only the composer internals – which the command above then removes.
This is an older question with valid answers, but somebody might find this helpful.
My problem was that I've had App instead of app in my directory path. Maybe this will help someone.
I am Xampp user on Windows 10. I try all of the above methods but none of them work for me. I fixed my problem with this method, and Hopefully, it will help others.
Create a directory C:\bin
Append ;C:\bin to your PATH environment variable (related help)
Download https://phar.phpunit.de/phpunit-5.7.phar and save the file as C:\bin\phpunit.phar
Open a command line (e.g., press Windows+R » type cmd » ENTER)
Create a wrapping batch script (results in C:\bin\phpunit.cmd):
C:\Users\username> cd C:\bin
C:\bin> echo #php "%~dp0phpunit.phar" %* > phpunit.cmd
C:\bin> exit
Open a new command line and confirm that you can execute PHPUnit from any path:
C:\Users\username> phpunit --version
PHPUnit x.y.z by Sebastian Bergmann and contributors.
This method solves my problem. Hope It will save your day too.
I had the same issue. For me it happened after I deleted a class dir and forgot to update composer.json.
The fix was simply updating the classmap array in composer.json
I think it happens because composer cache error. Try to clear its cache:
composer clearcache
then run the installer again
composer create-project --prefer-dist laravel/laravel blog
It generally happens when composer is unable to autoload classmap. Check whether the location to the file or folder is correct.
This happens due to your composer.lock file.
For instance in my case I was getting:
Could not scan for classes inside ".../vendor/drupal/core-composer-scaffold/PEAR/" which does not appear to be a file nor a folder
That directory indeed did not exist. However, search for 'PEAR' inside of your composer.lock... 'app/commands' in this case- and you will find the modules definition:
{
"name": "drupal/core-composer-scaffold",
"version": "8.9.11",
"source": {
"type": "git",
"url": "https://github.com/drupal/core-composer-scaffold.git",
"reference": "c902d07cb49ef73777e2b33a39e54c2861a8c81d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/drupal/core-composer-scaffold/zipball/c902d07cb49ef73777e2b33a39e54c2861a8c81d",
"reference": "c902d07cb49ef73777e2b33a39e54c2861a8c81d",
"shasum": ""
},
"require": {
"php": ">=4.4.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"type": "class",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"PEAR/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"."
],
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Helgi Thormar",
"email": "dufuz#php.net"
},
{
"name": "Greg Beaver",
"email": "cellog#php.net"
}
],
"description": "The PEAR Exception base class.",
"homepage": "https://github.com/pear/PEAR_Exception",
"keywords": [
"exception"
],
"time": "2019-12-10T10:24:42+00:00"
},
Our important piece is:
"autoload": {
"classmap": [
"PEAR/"
]
},
Composer is attempting to autoload from that directory, which is why you get a composer crash- that directory doesn't exist. Likely the same thing in your case of 'app/commands'.
Remove the entire package from your composer.lock- which for clarity is the longer code posting above. Then rerun your 'composer require' for that package. Example: composer require drupal/core-composer-scaffold.
In my case I needed a specific version, the default would give me version 9, I needed 8. My command was composer require drupal/core-composer-scaffold:^8.
Once this is done your composer install will run without a hitch.
Here is another debugging idea:
I accidentally added the vendor/ folder to my repository which then got deployed.
After removing it from the repository, the error message
composer RuntimeException Could not scan for classes inside polyfill-php80/Resources/stubs which does not appear to be a file nor a folder
disappeared.
in most of cases it is happen because of copy or cloning so try to remove or rename VENDOR folder from the magento installation and rerun "composer install".
In my case, I was installing wordpress plugins by composer, especially yoast (wordpress-seo) and woocommerce from packagist.org. I changed the sources to wpackagist and it started to work ok:
"require": {
"wpackagist-plugin/wordpress-seo": "dev-trunk",
"wpackagist-plugin/woocommerce": "dev-trunk"
}
I am trying to create a new composer library package.
I created the composer.json file using the
composer.phar create-project xlix vendor/xlix/xlix 0.3
command.
In the filesystem the file composer.json exists under vendor/xlix/xlix and for testing purposes I copied it to vendor/xlix.
The composer.json file content is the following:
{
"name": "xlix/xlix",
"type": "library",
"description": "XLIX package",
"keywords": ["core"],
"homepage": "http://myhomepage",
"license": "GPL",
"authors": [
{
"name": "Florian Kasper",
"email": "florian.kasper#mymail"
}
],
"require": {
"php": ">=5.2.4"
},
"autoload": {
"psr-0" : {
"Xlix\\Bundle" : "lib/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0"
}
}
}
Then I tried the following commands:
git:(master) ✗ php composer.phar require xlix/xlix
git:(master) ✗ php composer.phat require vendor/xlix
...
git:(master) ✗ php composer.phar install vendor/xlix
git:(master) ✗ php composer.phar install xlix/xlix
...
Every time the same output:
Please provide a version constraint for the xlix/xlix requirement: *
composer.json has been updated
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package xlix/xlix could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
In my ROOTDIR/composer.json file the package is registered in the require section.
"jms/security-extra-bundle": "1.2.*",
"jms/di-extra-bundle": "1.1.*",
"kriswallsmith/assetic": "1.1.*#dev",
"xlix/xlix": ">=0.*"
Now I am on the edge of despair an don't know what to do anymore.
Question:
Are there any mistakes I've made or is there anything i missed?
Packages live on the internet, not on your filesystem.
Composer searches by default for a package called xlix/xlix on packagist and that does not exists. You can add more package repositories by using the repositories configuration, more about that in the documentation.
So, in order to require your package with composer you need to upload your xlix directory somewhere.
I don't see what you are trying to do in the lxix directory? You are in the lxix package, why do you want to require it in the same package? It looks like you don't understand what those commands do and how composer works. Maybe a good read in their own documentation -- or some other tutorials about Composer (like the one on nettuts+) -- will help you to get a better understanding of composer.