Setting up alias for master branch in composer - composer-php

I am trying to package a module for use with composer. I have a valid composer file and I am able to install it with composer, but only when I specify that it should use dev releases (via the "#dev" version directive or minimum stability dev). I am having trouble packaging my repo so that it is seen as a master release.
I found a composer document about aliases that seems to be made for my case, but I cant get it working. Heres the relevant portion of my composer.json:
"extra": {
"branch-alias": {
"dev-master": "1.0"
}
}
Also for reference heres the require from my main projects composer file:
"require": {
"misterglass/kohana-twig" : "1.*"
},
And the actual error from composer is:
Problem 1
- The requested package misterglass/kohana-twig 1.* could not be found.

According to some helpful people on the #composer IRC channel, aliases are just to associate different versions to each other, and not to assign stability.
In order to for composer to consider it stable, you need to add a tag, which you can do on the command line or by creating a release in github.

Related

Laravel package class not found

I have installed laravel packages on staging server and packages working fine. But when i take pull on staging server, it is showing me error that package class not found.
Steps I have followed to resolve issue
I have check in vendor folder as well as in config/app.php, but I got class declaration and package folder is there.
After this when I update composer, my issue get resolved.
Is there any other file which should i look for class defination?
Perform a composer update, then composer dump-autoload.
If the above doesn't solve the problem, change the classmap in your composer.json file such that it contains the project-relative path to your php files:
"autoload-dev": {
"classmap": [
"tests/TestCase.php",
"database/seeds/UserTableSeeder.php" //include the file with its path here
]},
and soon after, perform a composer dump-autoload, and it should work now

Laravel 6 can not found vendor class from the fast-tuned package that was released for the Laravel 5

I am trying to use Firebird 3.0 from Laravel 6.0 and I am following https://firebirdsql.org/file/documentation/reference_manuals/fbdevgd-en/html/fbdevgd30-php-Laravel-crt-project.html where the package https://github.com/sim1984/laravel-firebird is suggested. Unfortunately, this package is intended for Laravel 5.7 (or maybe it has not been published in composer repositories) that is why I received the following message while I was trying to install this package:
[InvalidArgumentException]
Could not find a matching version of package sim1984/laravel-firebird. Check the package spelling, your version con
straint and that the package is available in a stability which matches your minimum-stability (dev).
So, I had this great ide to to fine tune this package that is why I forked it as https://github.com/alex153490/laravel-firebird, I changed the version requirements in its composer.json. I hope that there is not other work to be done to ensure the compatibility with Laravel 6. After that I added this git repository in the composer.json of my Laravel project:
"repositories": [
{
"type": "package",
"package": {
"name": "alex153490/laravel-firebird",
"version": "master",
"source": {
"url": "https://github.com/alex153490/laravel-firebird.git",
"type": "git",
"reference": "master"
}
}
}
]
Now the package was installed OK. I have created one model file in my Laravel project and I added the import
use Firebird\Eloquent\Model;
as was suggested by the original description of the original package.
But now I started to receive error
Symfony\Component\Debug\Exception\FatalThrowableError
Class 'Firebird\Eloquent\Model' not found
while trying to call this model class from the simple rest API controller of my project.
Why is this class not found error - the package was installed without error, the package sits inside the vendor folder of my project and all seems to be OK. I have checked the possible issues from the checklist https://dev.to/dechamp/php---how-to-fix-class--not-found-error-1gp9 , including I regenerated the autoload file for my project, but of no help.
What did I do wrong? Why it is so hard to make class visible from my package inside the vendor directory?
p.s. when I tried to use suggested Laravel-Firebird packages for Laravel 6 (https://packagist.org/packages/harrygulliford/laravel-firebird or https://github.com/KKSzymanowski/laravel-6-firebird) I always got the exception event for the most basic select statement:
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: -901 Dynamic SQL Error SQL error code = -901 feature is not supported (SQL: select * from "MY_TABLE")
It seems to me that the authors of the package has just provided data for the Firebird-specific grammar (includind the statements for the system data), but their ignored that Firebird can have some features missing for use from Laravel.

Php version overridden by "config.platform.php"

I'm trying to upgrade an application (magento) but I can't proceed as per the following error
your PHP version (7.0.22) overriden by "config.platform.php" version (7.0.2) doesnt satisfy requirements.
However there is not a config->platform setting in my composer.json. Viceversa, if I specify it or I add ignore-platform-reqs,s it works.
Tried to search also for the 7.0.2 or platform string over all the project but I can't see any can affect composer.
Any idea where the setting can be found?
You have to update your php version on the composer.json
"config": {
"platform": {
"php": "7.2"
}
},

Errors in the autoloaded HTTP/Request2 code, how to troubleshoot composer?

I have two different systems with a git repository cloned on them.
the project uses composer to install various dependencies.
One of these is pear/HTTP_Request2 which requires Net/URL2.
Both systems are Windows with a xampp development enviroment. So both run an Apache2 with a PHP 7.1.* installation.
On one of them everything works perfectly after installing via composer install. But the other one always Errors in the autoloaded HTTP/Request2 code:
<b>Warning</b>: require_once(Net/URL2.php): failed to open stream: No such file or directory in <b>C:\xampp\htdocs\XXX\vendor\pear\http_request2\HTTP\Request2.php</b> on line <b>25</b><br />
<br />
<b>Fatal error</b>: require_once(): Failed opening required 'Net/URL2.php' (include_path='C:\xampp\htdocs\XXX\vendor/pear/pear_exception;C:\xampp\htdocs\XXX\vendor/pear/http_request2;C:\xampp\php\PEAR') in <b>C:\xampp\htdocs\XXX\vendor\pear\http_request2\HTTP\Request2.php</b> on line <b>25</b><br />
Looking at the code in the Package we find:
if (!class_exists('Net_URL2', true)) {
require_once 'Net/URL2.php';
}
The dependency of NetURL2 was successfully installed, judging by composers output.
None the less I tried to fix it by also requiring the dependency from HTTP/Request2 "pear/net_url2" : "^2.2.0", in the Project after i heard from a bug (long closed but still) about problems with that (Issue#composer git), which didn't result in a change.
Judging by the inspected code I also assume this question is outdated.
Now I'm stuck not knowing what to do next... Help?
Edit:
My composer.json essentially looks like this if anyone was wondering:
{
"require":
{
"php":">=7.1.4",
"pear/http_request2": "v2.3.0",
"ext-json":"1.5.0",
"ext-PDO":"7.*",
"ext-pdo_mysql":"7.*",
"ext-mbstring":"7.*",
"ext-gd":"7.*"
},
"autoload": {
"files": [
"helper.php",
"settings.php"
],
"classmap": ["./"],
"exclude-from-classmap": ["vendor/"]
}
}
To troubleshoot Composer in general, you can add -vvv flags for verbose information.
Secondly, when you've XDebug extension for PHP installed, you will see a Call Stack each time when a Fatal error happens.
Note: Run phpenmod -s cli xdebug to enable XDebug in CLI mode.
The fatal error happens in pear/http_request2 package (as per vendor/pear/http_request2/HTTP/Request2.php) when it tries to include Net/URL2.php file (part of pear/net_url2, full path: vendor/pear/net_url2/Net/URL2.php).
This path should normally be added by Composer into include_paths.php like:
vendor/composer/include_paths.php: $vendorDir . '/pear/net_url2',
which failed to do so. To generate autoload files again, run this command:
composer dump-autoload -o
and check whether the autoload files under vendor/composer has been generated as expected.
To test that out, I've run this PHP command and it worked:
php -r 'require_once "vendor/autoload.php"; require_once "vendor/pear/http_request2/HTTP/Request2.php";'
Note: To see the failing scenario, remove include of autoload.php.

Alias and provider name unknown for github library

I am trying to install this github library:
https://github.com/robholmes/term-extractor
I used composer by adding this in composer.json under "require":
"robholmes/term-extractor": "dev-master"
However, I'm not sure what I would put in the app.php config file under providers and aliases. What would be the lines I would add there?
This is not a Laravel specific package. No need to add service providers, as they don't exist.
composer require robholmes/term-extractor dev-master
Instead, just include it in your controller for use, etc:
use TermExtractor\TermExtractor;
To test it works (it should), in your controller method just return this:
$term_extractor = new TermExtractor();
return dd($term_extractor);

Resources