How install the latest PHP minor branch version with composer - php

I am trying to manage branch with version number to have a control of the code. So I have a branch "0.7" and from this I create another branch "0.7.1" with a lot of changes.
I'm trying to install in other project my package with "0.7.1" branch code, and as the composer documentation say, the way to do this is define the jida dependency as "0.7.x-dev". But when I run "composer update" composer only download the 0.7 version and not the latest. I tried a lot of things but i can't download the 0.7.1 version. I want to fix this because my idea is later make a 0.7.2 versions and keep like that.
{
"type": "website",
"minimum-stability": "dev",
"license": "mit",
"authors": [
{
"name": "jr0driguez",
}
],
"require": {
"phpmailer/phpmailer": "^5.2",
"ext-json": "*",
"ext-gd": "*",
"jida/framework": "0.7.x-dev",
"ext-curl": "*"
},
"autoload": {
"psr-4": {
"App\\": [
"./Aplicacion/"
]
}
},
"scripts": {
"post-install-cmd": [
"npm install"
],
"post-update-cmd": [
"npm update"
]
}
}
I put an image with composer message where shows the ""

If your branch name is 0.7.1, you should use 0.7.1.x-dev as a constraint:
"jida/framework": "0.7.1.x-dev",

I resolved the trouble adding the "repositories" property into the composer.json from the project where I was installing the dependency.
This was the part:
{
"type": "git",
"url": "https://github.com/jidadesarrollos/jida",
"name": "jida/framework"
}
I set the "name" property to cofirm the dependency name, I think must be the same. And with this I could specify the branch name that I was needing to install
"jida/framework": "dev-desarrollo",
The branch where I'am working. I hope the post be useful to another.

Related

cant install cakephp 4 again

I have wamp64, php 7.4 and using composer I ran this from the console
composer create-project --prefer-dist "cakephp/app:^4.0" myapp
and
composer create-project --prefer-dist cakephp/app:~4.0 my_app_name
The installation cut out towards the end with this error
Script App\Console\Installer::postInstall handing the post create project cmd event terminated with an exception
[Symfony\Component\Console\Exception\RunTimeException\ Aborted
and some Symfony runtime exception when you get to the set folder permission y/n
It created this JSON file
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "https://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=7.2",
"cakephp/cakephp": "~4.2.0",
"cakephp/migrations": "^3.0",
"cakephp/plugin-installer": "^1.3",
"mobiledetect/mobiledetectlib": "^2.8"
},
"require-dev": {
"cakephp/bake": "^2.3",
"cakephp/cakephp-codesniffer": "~4.2.0",
"cakephp/debug_kit": "^4.4",
"josegonzalez/dotenv": "^3.2",
"phpunit/phpunit": "~8.5.0 || ^9.3",
"psy/psysh": "#stable"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
"dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.",
"phpstan/phpstan": "PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code."
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-create-project-cmd": "App\\Console\\Installer::postInstall",
"check": [
"#test",
"#cs-check"
],
"cs-check": "phpcs --colors -p src/ tests/",
"cs-fix": "phpcbf --colors -p src/ tests/",
"stan": "phpstan analyse",
"test": "phpunit --colors=always"
},
"prefer-stable": true,
"config": {
"sort-packages": true
}
}
How to Fix Cakephp 4 Composer Install Error
(i didnt understand the solution to this)
Cakephp 4 Windows Installation Issues
It should be possible to get it to work. What Windows version do you use? Pro or Home? Which distribution? 2010?
Please make sure to navigate to the WAMP install folder and then specifically the www folder.
The command I use is this;
composer create-project --prefer-dist cakephp/app:~4.0 cake
It worked for me.
Alternatively, download Cakephp version 4.0, place the contents in the www folder, and configure it manually through the file /config/app.php. If you want, we can look at it together. There are not many people around me that can or want to work on Cakephp, so it'd be a pleasure. :)

Composer doesn't autoload custom package

acknowledgement:
First of all this is my first post for help, as i went trough a lot of articles on stackoverflow and other resources and just could not find solution.
Problem sounds familiar but i just can't figure it out, maybe because im stuck on it for 2 days now. Another note, this is my first package so yes im not 100% sure what im doing.
Structure:
- laravel-project
- ...
- packages
- my-custom-package
- src
- MyCustomPackageServiceProvider.php
- composer.json
- public
- resources
- routes
- ...
- composer.json
So it is basic Laravel 5.8 + inside added package folder for local package devolment (it has been moved to repo as well)
Current Code (simplified as its actual work project):
File: laravel-project/packages/my-custom-package/composer.json
{
"name": "company/my-custom-package",
"type": "library",
"require": {
"php": ">=7.2",
},
"require-dev": {
"ext-curl": "*"
},
"authors": [
{
"name": "John Smith",
"email": "jsmith#test.tv"
}
],
"autoload" : {
"prs-4": {
"Company\\MyCustomPackage\\": "src/"
}
},
"minimum-stability": "dev"
}
File: laravel-project/packages/my-custom-package/src/MyCustomPackageServiceProvider.php
<?php
namespace Company\MyCustomPackage;
use Illuminate\Support\ServiceProvider;
class MyCustomPackageServiceProvider extends ServiceProvider {
public function boot()
{
$this->loadRoutesFrom(__DIR__ . '/routes/web.php');
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
}
public function register()
{
}
}
File: laravel-project/composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"repositories": [
{
"type": "path",
"url": "~/testlaravel/packages/my-custom-package",
"options": {
"symlink": true
}
}
],
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"guzzlehttp/guzzle": "^6.3.3",
"company/my-custom-package": "dev-master"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"prs-4": {
"Company\\MyCustomPackage\\": "~/testlaravel/packages/my-custom-package/src"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
Explanation: ~/testlaravel/ is folder path inside Vagrant machine for project originaly url was "packages/my-custom-package" buti changed for this extended version just in pure attempt of making it work.
File: config/app.php (added service provider)
Company\MyCustomPackage\MyCustomPackageServiceProvider::class
Issue:
First i made this thing localy and it worked i was following for quick setup instructions from
"Create Laravel Composer Package from scratch to upload on packagist" Author: Bitfumes, and package worked, I could run composer update, then i added to app.php my package and i could run custom route and it all worked.
After that i moved package to git repo, and required it in same way only changed "repositories" field to
"repositories": [
{
"type": "vcs",
"url": "git#git.fulllink.co:john/my-custom-package.git"
}
]
and when you run composer update, you can see that afterwards inside vendor/ files you have Company folder with package inside it, BUT if you leave config/app.php service provider it starts to complain that there is
*Class 'Company\MyCustomPackage\MyCustomPackageServiceProvider' not fo und*
After some f*** around i found out that yes my autoload_classmap (cant remember original post) did not contain my package , so today i decided to try again local and see the difference, does it been added to map file, and now i get same error when requiring local package and i can't make it work anymore.
I been deleting vendor folder and lock file , composer dump-autoload, but that doesnt help. Im just thinking is thgere anything else supercached?
!!UPDATE!!
Im not even more confused. In composer.json (project one i tested on actual project repo now where is required another 2 local git repos). So i have now 4 packages in vendor/Company/{4 packages} , i compared all 4 package composer.json and i can't find any major difference but all of them have been loaded to autoload mapping except mine. Only major difference i can see, those two packages doesnt use ServiceProvider.php file , but i dont see how that impacts or changes things.

Composer does not respect installer-paths

Here is the scenario:
I have two projects driven by composer. The first one looks like this:
{
"name": "myusername/composer_test",
"description": "Composer project for CircleK Drupal 8",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Name Surname",
"role": "webdeveloper"
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"php": ">=5.6",
"composer/installers": "^1.2",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/core": "^8.7.0",
"vlucas/phpdotenv": "^2.4",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3",
"zaporylie/composer-drupal-optimizations": "^1.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"]
}
}
}
Second one requires the first one and it's pretty straight forward:
{
"name": "user/site",
"description": "Composer for Site",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Name Surname",
"role": "webdeveloper"
}
],
"repositories": [
{
"type": "git",
"url": "git#github.com:myusername/composer_test.git"
},
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"myusername/composer_test": "dev-drupal_only"
},
"minimum-stability": "dev",
"prefer-stable": true
}
As you can see the first one defines where drupal core should be placed at by defining installer-paths. It turns out that when I run composer install just for the first composer.json file drupal core ends up in ./web directory as should, however when I run composer install for second file it does download every package from first composer.json just fine, but drupal core ends up in main directory instead of ./web. I know I can put installer-paths into the last composer file and overwrite it, but that's not the point. I want first file to define where stuff should be place at.
The extra settings only work for the root package. Consider user/site requiring 2 different packages that both specifiy different installer paths. Which one should composer use and how should it know? By ignoring those settings, unless they are specified in your root composer.json, composer circumvents any surprises/problems.
There is a way around this, you can create a post-install script that determines the correct path for you, e.g. by checking if myusername/composer_test is installed and the variable is set. This is a bit similar to how Symfony's Install-Script in the SensioDistributionBundle used to do it. It provides a fallback to determine the right directory to use based on configs and folder structure (due to changes in how the default directory structure looks at ~2.8, e.g. moving app/console to bin/console).
You could write your own install script that inspects the installed composer packages. The downside is, that just like you now have to specify the extra config in your second composer.json, you will have to specify the install scripts, plus you have to write the install script itself. So it might be a lot of extra work without gaining a lot from it.

Can't require local package with composer

I'm currently working on a Composer package and now I want to test how it would integrate in my current application without pushing it to a remote.
So I stumbled upon this blog post which explains how to do that. However, that didn't work. I'm getting the message
Your requirements could not be resolved to an installable set of packages.
Problem 1 - The requested package tzfrs/x-bundle could not be found in any version, there may be a typo in the package name.
My directory structure looks like this
dev
Project
composer.json
Package
composer.json
The composer.json of my package looks like this
{
"name": "tzfrs/x-bundle",
"license": "proprietary",
"require": {
"php": "^7.0",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~5.5"
},
"autoload": {
"psr-4": { "tzfrs\\XBundle\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
}
}
And the one of my project looks like this (I'm leaving the symfony stuff and other packages/stuff out)
{
"repositories": [
{
"type": "git",
"url": "../Package",
}
],
"minimum-stability" : "beta",
"require": {
"tzfrs/x-bundle": "*"
}
}
So when doing composer update tzfrs/x-bundle I should get my new project right? However, I'm getting the message I posted above. What am I doing wrong here?
I already did git init in my package folder and also comitted all my changes. So I have a repo which is not empty already.

The requested package ... could not be found in any version

When I want to require my project, the following errors shows up:
The requested package mvc-php/framework could not be found in any version, there may be a typo in the package name.
The "mvc-php/framework" is a git folder.
{
"name": "mvc-php/app",
"repositories": [
{
"type": "path",
"url": "/Users/youri/Documents/Github/framework"
}
],
"require": {
"php": ">=7.0",
"mvc-php/framework": "master"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
}
Project i want to require:
{
"name": "mvc-php/framework",
"description": "PHP MVC framework",
"autoload": {
"psr-4": {
"Mvc\\" : "src/"
}
},
"require": {
"php": ">=7.0"
}
}
Instead of just the branch name, you must require branchName#dev
https://getcomposer.org/doc/articles/versions.md#branches
{
"name": "mvc-php/app",
"repositories": [
{
"type": "path",
"url": "/Users/youri/Documents/Github/framework"
}
],
"require": {
"php": ">=7.0",
"mvc-php/framework": "master#dev"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
}
The requested package X/Y could not be found in any version.
The requested package needs to be a git folder with the committed and existing composer.json file. Then to reference specific branch, you need to add the dev- prefix, so dev-master, not master.
Example
Here is the minimal working example:
File: composer.json
{
"require": {
"local/my_package": "dev-master"
},
"repositories": [
{
"packagist.org": false
},
{
"type": "path",
"url": "my_package/"
}
]
}
File: my_package/composer.json
{
"name": "local/my_package",
"require-dev": {
"symfony/console": "*"
}
}
Note: Above file is under local Git repository. To create one, run: git init && git commit -am 'Files'.
Troubleshooting
To troubleshoot the issue, run:
composer install -vvv
Also consider running: composer diagnose to identify common Composer errors.
As this is the first response when searching the error text on Google, I will also put my fix here, despite not being 100% relevant to the OP.
When you are requiring the repo, you need to make sure that your requires statement matches the name of the project in the composer.json of the project.
So if the name had been "name": "mvc-php/app-framework", in the framework project, then the require would need to be:
"require": {
"mvc-php/app-framework": "dev-master"
},
This is more applicable when you are adding a git repo. Especially when forking, as sometimes the git url might be different from the composer.json name.
Additionally (and this is the part relevant to OP), you now need to do dev-branch_name instead of branch_name#dev when requiring. I don't know when this changed, or if the old method is unusable. But this is what the current composer docs now say.
If you want Composer to check out a branch instead of a tag, you need to point it to the branch using the special dev-* prefix
Composer Documentation - Versions and Constraints - Branches
Another Gotcha to be Aware Of:
I changed the name of a package I developed and was just testing a branch on it. I had followed all the correct naming conventions mentioned above but was still getting the given error.
It turns out that for the name change to be picked up, you have to update the package name in composer.json on the main branch of the package repo (Master for me) even if you are not using that branch within your project.
It is important to note that if you do not add your own mirror source to the global variable, an error will occur where the sub-scene is not found.
You can add this in composer.json:
"repositories":[
{
"type":"composer",
"url":"https://packag"
}
],

Categories