I have a satis private repo set up on the url http://packages.ex/, which, when I visit it, lists two packages: example/admin and example/codebase
When I run composer create-project example/codebase new-site --repository-url=http://packages.ex stability=dev I get the error:
[InvalidArgumentException]
Could not find package example/codebase with version stability=dev.
The composer.json inside example/codebase looks like this:
{
"name": "example/codebase",
"description": "Example codebase.",
"keywords": ["codebase", "example"],
"homepage": "http://www.exampple.com",
"version": "0.1",
"repositories": [ { "type": "composer", "url": "http://packages.ex/" } ],
"authors": [
{
"name": "Example",
"email": "example#example.com"
}
],
"require": {
"php": ">=5.4.0",
"ext-mcrypt": "*",
"laravel/framework": "4.1.*",
"way/generators": "dev-master",
"example/admin": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
I don't know why composer can't find the package as when I visit the private repo in a browser it's there, and I'm specifying 'minimum-stability': 'dev' in composer.json.
Maybe I'm missing something or doing something wrong. Any ideas?
Is there any way to run a command line check to see if composer can access a particular package and what stabilities it has?
Looks like you have an error or typo in your repository-url parameter and composer try to find package on default packagist.org repo.
Related
I am trying to modify an existing composer package.
I forked the original package from github, cloned it on my local machine and now trying to make my laravel app use it with the following composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "5.6.*",
....
"vendor/packagenamehere": "dev-dynamic-logo",
....
},
"minimum-stability": "dev",
"repositories": [
{
"type": "composer",
"url": "https://www.setasign.com/downloads/"
},
{
"type": "path",
"url": "path/to/package/on/my/machine",
"options": {
"symlink": true
}
}
],
"require-dev": {
"fzaninotto/faker": "~1.4",
"laravel/dusk": "^1.0",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7",
"staudenmeir/dusk-updater": "^1.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/env.php",
....
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Then im firing composer update vendor/packagename --prefer-dist - and nothing.
No matter what I try, composer still grabs from packagist.
Any ideas?
From https://getcomposer.org/doc/05-repositories.md#path :
If the package is a local VCS repository, the version may be inferred by the branch or tag that is currently checked out. Otherwise, the version should be explicitly defined in the package's composer.json file. If the version cannot be resolved by these means, it is assumed to be dev-master.
Make sure that the "dynamic-logo" branch is checked out in your cloned package repo or update the version in the composer.json of the package.
Also check that the name of the package declared in it's composer.json matches your "vendor/packagename".
Basically a fresh git clone of a working repo...
When I try to composer install I get an error.
Seems like the laravel folders are not being installed the way composer expects to look for them? I tried updating/installing composer, deleting folders and clearing caches already.
I suspect I need to change composer.json or maybe revert to an older composer?
composer.json
"require": {
"laravel/framework": "4.2.*",
"zizaco/confide": "~3.2",
"zizaco/entrust": "~1.2",
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"paypal/rest-api-sdk-php" : "*"
},
"require-dev": {
"barryvdh/laravel-debugbar": "~1.8",
"way/generators": "~2.6"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
[RuntimeException]
Could not scan for classes inside "[mysite]/vendor/laravel/framework/src/Illuminate/Queue/IlluminateQueueClosure.php" which does not appear to be a file nor a folder
I pushed some changes to our repo and they auto-deployed to Forge. The deployment failed with this error:
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'MyRepo\MyPackage\MyServiceProvider' not found
Script php artisan optimize handling the post-install-cmd event returned with error code 1
So I edited the config/app.php file to temporarily comment out that service provider line, then re-ran composer update without any problems to artisan optimize this time.
I then uncommented the service provider line and ran artisan optimize again to make sure all was well and got no errors.
Because the composer.lock file changed on Forge after this composer update, I pushed it to the repo.
This triggered yet another artisan optimize error for that same service provider. So I repeated my steps above.
Now every single time there is a new deploy from the repo, artisan optimize triggers that error on that service provider even if we didn't add new service providers.
If I simply run composer update then I'm right back with the same artisan optimize error as before.
Tried doing composer clear-cache but that didn't fix it.
I ran a test script to make sure that service provider is working and autoloaded as expected by calling the class it loads, so I've verified the PSR-4 namespace works just fine.
Here is my project composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"laravel/framework": "5.2.*",
"laravel/cashier": "~6.0",
"my-repo/my-package": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.6",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5",
"phpunit/phpunit-mock-objects": "3.2.*#dev"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": [
{
"type": "git",
"url": "git#bitbucket.org:my-repo/my-package.git"
}
]
}
Here is our private package's composer.json:
{
"name": "my-repo/my-package",
"description": "My package.",
"type": "package",
"require": {
"php": ">=5.5.9",
"illuminate/support": "5.2.*"
},
"require-dev": {
"raveren/kint": "~1"
},
"autoload": {
"psr-4": {
"MyRepo\\MyPackage\\": "src/"
},
"files": [
"src/MyPackage/helpers.php"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
Even if I change the project's composer.json to pull this by {"type": "path", "url": "./library/my-repo"} I get the same error.
It's as if the optimized class loader is cleared of private repo classes every time I run composer update.
I'm pretty stuck here.
I'm new to Laravel and PhpUnit and I'm trying to run some tests located in the \App\Tests\Unit folder on customs classes located in the \App\Musibits directory.
I get the following when I run phpunit in the \App\Tests\Unit directory:
Fatal error: Class 'Tonality' not found in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\musibits\app\tests\TonalityTest.php on line 8
Tonality.php contains my class and is in the \App\Musibits directory
I read numerous posts about autoloading and bootstrap, but I can't seem to make it work :-(
Here is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/musibits",
"app/tests"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
There is three autoload files included with Laravel, one for composer, one for phpunit and one for Laravel, I didn't change any.
Any cues would be greatly appreciated.
Thanks,
Phil
You should probably run
composer dump-autoload
to generate new class map
After downloading hybridauth from composer, I always need to manually add the hybridauth's directory in /vendor/composer/autoload_classmap.php, this should be automatic.
Below is my composer.json, can someone point me the problem why hybridauth is not getting written in autoload automatically?
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"require": {
"laravel/framework": "4.0.*",
"way/generators": "dev-master",
"hybridauth/hybridauth": "*",
"intervention/image": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
Have you tried
using "hybridauth/hybridauth": "dev-master"
also try
artisan dump-autoload command
Looks like in the latest update they have changed lot of things and your old code won't work with it.
If you are not getting autoload classes in classmap file then better use older version of HybridAuth i.e. 2.9.1
use "hybridauth/hybridauth": "2.9.1" instead of "hybridauth/hybridauth": "dev-master"
Classes will be loaded automatically on autoload classmap file.
This works well on laravel 4 and 5 both.