I'm developing a package in Laravel 5.5 where I need this package:
https://github.com/laracasts/PHP-Vars-To-Js-Transformer
The problem is that It's not registering for some reason. When I dd in the JavaScriptServiceProvider.php nothing happens. When I use the Javascript facade I get an error that it does not exists?!
My package composer.json file:
"require": {
"php" : "^7.0",
"illuminate/support": "~5.5.0",
"laracasts/utilities": "^3.0"
},
I use Laravel 5.5 so it should be registered by default (composer.json from laracasts package):
"extra": {
"laravel": {
"providers": [
"Laracasts\\Utilities\\JavaScript\\JavaScriptServiceProvider"
],
"aliases": {
"JavaScript": "Laracasts\\Utilities\\JavaScript\\JavaScriptFacade"
}
}
}
What am I doing wrong here?
I faced the same problem using different other packages in my own package.
Here are the steps that worked for me:
Add the required package as a dependency in your own package:
composer require laracasts/utilities
Update your package in the Laravel project (e.g. by incrementing the version number or by removing your package and reinstalling it.
composer update # in main Laravel project
Then you should see, that in the main Laravel project there is auto-discovery of your own package and the dependency to laracasts/utilities.
Let me know if this helped you or if I can give more assistance.
You need to following steps, to solve this issue :
Run the command in your packages directory :
composer require laracasts/utilities
Now use this in your package (on top of the file) whenever you want to use this dependency:
use Laracasts\Utilities\JavaScript\yourClassName
Related
I've created a package (innovareti/password-policy) and now I am trying to install it, but it is not found:
$ composer require innovareti/password-policy
...
[InvalidArgumentException]
Could not find a version of package innovareti/password-policy
matching your minimum-stability (dev). Require it with an explicit
version constraint allowing its desired stability.
(this error keeps ocurring)
It does have a tag and a release, and I've updated it in packagist but it's still not working, even after the update on packagist is done already for a couple of minutes and I can see it there fine.
This is the composer.json of the package:
{
"name": "innovareti/password-policy",
"description": "A library to intuitively create password policies and validate a subject against them.",
"autoload": {
"psr-4": {
"PasswordPolicy\\Tests\\": "tests/",
"PasswordPolicy\\": "src/PasswordPolicy/",
"PasswordPolicy\\Database\\Factories\\": "database/factories",
"PasswordPolicy\\Models\\": "src/Models"
}
},
"extra":{
"laravel": [
"src/PasswordPolicy/Providers/Laravel/PasswordPolicyServiceProvider"
]
},
"require": {
"php": "^5.5"
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-f": "vendor/bin/phpunit --filter"
},
"minimum-stability": "dev"
}
My repository is at: https://github.com/innovareti/password-policy
I've tried many things I saw online but nothing worked, can anyone help me?
Apparently the problem was that new packages published to packagist need to be installed with composer on version 21.
I ran composer selfupdate --2 to update my version of composer which was 1.x.
Then required my package by running composer require innovareti/password-policy and it worked.
Compare "Restricted access to unused packages via the v1 metadata API starting in May 2021" in Deprecating Packagist.org support for Composer 1.x (
Jordi Boggiano for packagist.org; Feb 2021)
Further References
Upgrade guides for Composer 1.x to 2.0 (Composer Documentation)
Composer 2.0 Compatibility (Private Packagist Documentation)
I forked an api handler from git that I need to update to be laravel 6 (api handler that i forked what is not laravel 6 compatible) compatible but I keep getting composer errors
So when I run composer update it install the package from the git and put it correctly on in the vendor folder. what works fine then I add the class to the config/app.php like this
'providers' => [
Name\ApiHandler\ApiHandlerServiceProvider::class,
],
what will throw this error in laravel
In ProviderRepository.php line 208:
Class 'Name\ApiHandler\ApiHandlerServiceProvider' not found
so far I have tried:
composer clear-cache
rm -rf .cache/composer/*
clear the bootstrap composer
delete composer.lock
delete the vendor
and then after that composer update but it keeps throwing the error. But when I am in mine editor and go to the config/app.php and click on Name\ApiHandler\ApiHandlerServiceProvider::class, while holding ctrl it finds the class and goes to the vendor map so mine idea shows that the class is correctly imported
this is how the composer.json looks of the laravel project
"repositories": [
{
"type":"package",
"package": {
"name": "name/laravel-api-handler",
"version":"dev-laravel-6",
"source": {
"url": "https://github.com/name/laravel-api-handler",
"type": "git",
"reference":"branch name"
}
}
}
],
"require": {
"name/laravel-api-handler": "dev-laravel-6",
},
the api handler composer.json
"autoload": {
"psr-4": {
"name\\ApiHandler\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"name\\ApiHandler\\ApiHandlerServiceProvider"
]
}
},
the map structure is vendor/name/laravel-api-handler/src
also the the custom package doesnt show up in the Discovered Package when running Composer update or Composer install
Am I missing something because I cant figure out what is going wrong
To resolve it,
remove the bootstrap/cache/config.php file. Then run again.
Run below commands one by one
composer dump-autoload
php update
Import the ApiHandler facade into your classes:-
use ApiHandler\Facades\ApiHandlerServiceProvider;
On top
Try to remove/rename your vendor folder. Then do composer install. Then please check again. If that doesn't work, do composer update. Not sure about what is happening under hood, but composer update did the trick in my case.
So after doing research to editing custom packages into your project apparently composer doesn't autoload "type":"package" what is not mentioned in there documentation anywhere. link where it get explained
I am trying to use the IronMQ driver in the latest version of Laravel (5.2) and am getting the below error;
Class 'Collective\IronQueue\IronQueueServiceProvider' not found
Here is my configuration.
composer.json:
"iron-io/iron_mq": "~2.0"
config/app.php:
'providers' => [
Collective\IronQueue\IronQueueServiceProvider::class,
],
Try to use version 3 :
"iron-io/iron_mq": "~3.0"
And don't forget to update your composer :
composer update
Hope this helps.
I managed to fix the issue by adding:
"laravelcollective/iron-queue": "5.2.*"
to composer and then running update:
composer update
It doesn't mention this step on the Laravel Collective website.
Solved: I've added the php and illuminate/support packages into my package composer.json file and it started working. I've got no idea why though so if someone could explain, I would really appreciate it.
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
},
I've created a composer package for Laravel 5 which should generate models based on an existing database schema. However i'm unable to load it in.
I add my Command class into the app/Console/Kernel.php
'Iber\Generator\Commands\MakeModelsCommand'
But then I get the following error:
Class Iber\Generator\Commands\MakeModelsCommand does not exist
I'm really new to Laravel and I'm not sure why this is happening since composer generates the autoloader file just fine. I've created and added (into config/app.php) a Service Provider but that doesn't get resolved either. Not sure what I'm doing wrong.
Here's the package:
https://github.com/ignasbernotas/laravel-model-generator
Apparently adding the required attribute with the following packages solved the issue. I'm still not sure why.
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
},
Ok, I'm using Yii2 and I am trying to add a new requirement/library to the project. Said library can be found here: https://github.com/cyphix333/SBBCodeParser
It is a forked project with an added composer.json.
I tried adding it as a requirement in the projects main composer file, ie:
"require": {
//..........
"samclarke/sbb-code-parser": "*"
},
Then I ran:
composer update
It just complained that it couldn't find the package or any version of it.
Then I removed that line and tried:
require samclarke/sbb-code-parser
I have the files already in my Yii vendor folder located at: #app/vendor/samclarke/sbb-code-parser
I'm pretty new to composer and am not sure what I'm doing wrong or how composer actually is supposed to know where to get the files from based on the package name.
The package samclarke/sbb-code-parser can be found at Packagist.
https://packagist.org/packages/samclarke/sbb-code-parser
By default Composer tries to resolve a stableset of packages.
But this packages doesn't provide a stable version (version tag), yet - only the dev-master version exists. Composer can not resolve it.
In order to require it, you need to lower your minimum-stability for this package to development.
You might do this for one package explicitly:
"require": {
"samclarke/sbb-code-parser": "dev-master#dev"
},
Or for all packages by setting:
"minimum-stability": "dev"
The package cyphix333/SBBCodeParser is not on Packagist.
It's a private fork. If you want exactly this code. You might add a repositories section to your composer.json and add repo with url and type with vcs there. Then Composer can load the package from the VCS repository over at Github. This is described here: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
That would work like this:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/cyphix333/SBBCodeParser"
}
],
"require": {
"samclarke/sbb-code-parser": "dev-master"
}
}
But unfortunately, the fork is also not well maintained and doesn't contain a valid composer.json file.
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https://github.com/cyphix333/SBBCodeParser, could not load a package from it.
This needs to be fixed first....