How to work on a fork in GitHub - php

I would like to update a repo in GitHub to make it compatible with ZF3, I have forked the repository to my account and made some updates.
This is my fork: https://github.com/chateaux/zf-oauth2-doctrine
Now to include this in my code base I am using Composer:
{
"name": "My Project",
"description": "",
"license": "PRIVATE - ",
"keywords": [
""
],
"homepage": "",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/chateaux/zf-oauth2-doctrine"
}
],
"require": {
"php": ">=5.4",
"zendframework/zendframework": "^2.4",
"doctrine/doctrine-orm-module": "~0.8",
"doctrine/orm": "^2.4",
"gedmo/doctrine-extensions": "^2.4",
"zf-commons/zfc-rbac":"^2.5",
"rwoverdijk/assetmanager": "^1.4",
"zfcampus/zf-apigility": "^1.0",
"zfr/zfr-cors": "^1.2",
"hounddog/doctrine-data-fixture-module": "^0.0.4",
"zfcampus/zf-oauth2-client": "dev-master",
"api-skeletons/zf-oauth2-doctrine": "dev-master",
"api-skeletons/zf-oauth2-doctrine-console": "^1.1",
"chateaux/toolbox" : "dev-master"
},
"require-dev": {
"zfcampus/zf-apigility-admin": "~1.0",
"zfcampus/zf-development-mode": "~2.0",
"zendframework/zend-developer-tools": "dev-master"
}
}
However when I run a composer update, it appears to be pulling from a cache so I am not getting my updated code base:
$ php composer.phar update
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Warning: This development build of composer is over 60 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version.
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing zfcampus/zf-oauth2-doctrine (1.0.3)
Loading from cache
What am I doing wrong?

You should add your custom fork of the repository to the repositories array in your composer.json file and add a type field git and then point to the branch you want to use with dev-[branchname] (for example patch-4 becomes dev-patch4):
{
"name": "My ZF2 application",
"repositories": [
{
"type": "git",
"url": "https://github.com/chateaux/zf-oauth2-doctrine.git"
},
],
"require": {
...
"zfcampus/zf-oauth2-doctrine": "dev-patch-4",
...
}
}
Make sure that patch-4 is an existing branch in your custom repository.
You can find more information on this solution on the first hit from Google.

Related

Magento 2 website with multiple errors (HTTP Error 500, PHP Warning, among others) can't make it work again

we currently have a locally hosted Magento test site and some time ago it was working OK but after doing some changes it stopped working and constantly shows HTTP Error 500. I am new to Magento and to Linux (we use here a Gentoo Linux machine) and I tried to research as much as I can, testing different solutions, but the problem persists and I have the idea that is getting worse every time I try to resolve something.
The problem I am having now inside the Terminal is a PHP Warning and PHP Fatal Error related to the 'require' function. Every time I try to do something about Magento I have this error (for example, if I run 'php bin/magento --version' I have this error, and so on with every command related with Magento). As far as I understand, this problem occurs when you try to call for a file that doesn't exists or is not there. In my case trouble seems to be related with the Sage Pay extension. This is the warning I have inside Terminal:
PHP Warning: require(/var/www/localhost/htdocs/vendor/composer/../ebizmarts/sagepaysuite/registration.php): failed to open stream: No such file or directory in /var/www/localhost/htdocs/vendor/composer/autoload_real.php on line 73
PHP Fatal error: require(): Failed opening required '/var/www/localhost/htdocs/vendor/composer/../ebizmarts/sagepaysuite/registration.php' (include_path='/var/www/localhost/htdocs/vendor/magento/zendframework1/library:.:/usr/share/php7:/usr/share/php') in /var/www/localhost/htdocs/vendor/composer/autoload_real.php on line 73
Thinking that this could be related to the extension itself being missing for some reason, when I try to install the extension I have this error:
Installation failed, reverting ./composer.json to its original content.
[RuntimeException]
Failed to execute git clone --no-checkout -- 'https://MHuYqyU63hS4dojaex1J:
***#gitlab.ebizmarts.com/ebizmarts/magento2-sage-pay-suite.git' '/var/www/l
ocalhost/htdocs/vendor/ebizmarts/sagepaysuite' && cd '/var/www/localhost/ht
docs/vendor/ebizmarts/sagepaysuite' && git remote add composer -- 'https://
MHuYqyU63hS4dojaex1J:***#gitlab.ebizmarts.com/ebizmarts/magento2-sage-pay-s
uite.git' && git fetch composer && git remote set-url origin -- 'https://gi
tlab.ebizmarts.com/ebizmarts/magento2-sage-pay-suite.git' && git remote set
-url composer -- 'https://gitlab.ebizmarts.com/ebizmarts/magento2-sage-pay-
suite.git'
Cloning into '/var/www/localhost/htdocs/vendor/ebizmarts/sagepaysuite'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.ebizmarts.com/ebizmarts/ma
gento2-sage-pay-suite.git/'
Similarly, when I try to update Composer I have the same error related to Sage Pay and the update is aborted.
Our current composer.json file is as follows:
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"absolute_design/absolute-slider": "^2.0.0",
"bitware/speedenginedeferjs": "^1.0",
"ebizmarts/sagepaysuite": "~1.3",
"magefan/module-wysiwyg-advanced": "^2.0",
"magento/data-migration-tool": "~2.3",
"magento/product-community-edition": "~2.3.7-p1",
"mageplaza/magento-2-english-united-kingdom-language-pack": "dev-master",
"mageplaza/magento-2-seo-extension": "^2.1",
"mageplaza/module-ajax-layered-navigation": "^1.0",
"mageplaza/module-delete-orders": "^1.2",
"mageplaza/module-gdpr": "^1.2",
"mageplaza/module-sitemap": "^1.0",
"olegkoval/magento2-regenerate-url-rewrites": "^1.5",
"trustpilot/module-reviews": "^2.6"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"friendsofphp/php-cs-fixer": "~2.14.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "~3.0.0",
"magento/magento2-functional-testing-framework": "2.4.5",
"pdepend/pdepend": "2.5.2",
"phpmd/phpmd": "#stable",
"phpunit/phpunit": "~6.5.0",
"sebastian/phpcpd": "~3.0.0",
"squizlabs/php_codesniffer": "~3.4.0"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
}
},
"version": "2.3.0",
"minimum-stability": "stable",
"repositories": {
"0": {
"type": "composer",
"url": "https://repo.magento.com/"
},
"magento": {
"type": "composer",
"url": "https://repo.magento.com"
},
"ebizmarts": {
"type": "composer",
"url": "https://packages.ebizmarts.com"
}
},
"extra": {
"magento-force": "override"
}
}
Any help would be appreciated, I am very lost and stuck right now not knowing how to resolve this.
Thanks in advance.
Maybe issue from extension ebizmarts/sagepaysuite
you can check file composer.json in this extension. In file composer.json you can see lable "require" php version for this extension.
=> you can delete this extension or upgrade you php version.
have a nice day !

but these conflict with your requirements or minimum-stability

I am creating my own slackbot. I decided to use project as a library to help me.
https://github.com/sagebind/slack-client/issues?utf8=%E2%9C%93&q=stability
Now I need to install it with composer.
So I used the command: composer require coderstephen/slack-client
...And I get the error:
Problem 1
- Installation request for coderstephen/slack-client ^0.3.0 -> satisfiable by coderstephen/slack-client[v0.3.0].
- coderstephen/slack-client v0.3.0 requires devristo/phpws dev-master -> satisfiable by devristo/phpws[dev-master] but these conflict with your requirements or minimum-stability.
Ok - So then I decided to change my stability level to "dev" in my composer.lock:
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"devristo/phpws": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=5.5"
},
"platform-dev": []
Now I'm running out of ideas on what to do. The README says to do this step in composer.json but, no such settings exist:
Please note that the current version has unstable dependencies.
In order to install those dependencies, you can set "minimum-stability" in your composer.json, and recommend that you set "prefer-stable":
My composer.json:
{
"name": "coderstephen/slack-client",
"keywords": ["slack", "api", "realtime"],
"license": "MIT",
"description": "A better Slack client, with RTM API support",
"authors": [{
"name": "Stephen Coakley",
"email": "me#stephencoakley.com"
}],
"require": {
"php": ">=5.5",
"devristo/phpws": "dev-master",
"evenement/evenement": "2.0.*",
"guzzlehttp/guzzle": "~6.0",
"react/event-loop": "^0.4.1",
"react/promise": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"fzaninotto/faker": "~1.4",
"apigen/apigen": "^4.1"
},
"autoload": {
"psr-4": {
"Slack\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Slack\\Tests\\": "tests"
}
}
}
Does anyone know some solutions I could try?
Add minimum-stability and prefer-stable to your composer.json (not composer.lock):
{
"name": "coderstephen/slack-client",
"keywords": ["slack", "api", "realtime"],
"license": "MIT",
"description": "A better Slack client, with RTM API support",
"authors": [{
"name": "Stephen Coakley",
"email": "me#stephencoakley.com"
}],
"require": {
"php": ">=5.5",
"devristo/phpws": "dev-master",
"evenement/evenement": "2.0.*",
"guzzlehttp/guzzle": "~6.0",
"react/event-loop": "^0.4.1",
"react/promise": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"fzaninotto/faker": "~1.4",
"apigen/apigen": "^4.1"
},
"autoload": {
"psr-4": {
"Slack\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Slack\\Tests\\": "tests"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
For others having the same issue, these changes are best done using composer itself instead of manually modifying the composer.json file. Just run the following commands in the console:
$ composer config minimum-stability dev
$ composer config prefer-stable true
Now you can require and update the package:
$ composer require --no-update "vendor/package-name:version"
$ composer update
Available options (in order of stability) are dev, alpha, beta, RC, and stable
You should never manually edit the composer.lock file - it is an automatically generated file.
It looks like you've shown the composer.json file of the package you're trying to require rather than your own project's composer.json. The prefer-stable and minimum-stability properties should be added to your project root's composer.json file:
{
"name": "xFlare/slack-bot",
"description": "xFlare's Slack bot project",
"authors": [
{
"name": "xFlare"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.5",
"coderstephen/slack-client": "^0.3.0"
}
}
Usually, this issue has nothing to do directly with minimum-stability or prefer-stable option, but the case is just that you already use some library directly or indirectly, that is needed in another library you use but in a higher version.
My case: Got this error message for a Codeception library which needed a dependency of PHPUnit at least of version 6 and above (>= 6) , but it clashed with the lower version 4 of PHPUnit dependency, which I had installed/required directly already before prior it (as a package in my composer.json file). (my specific case could not use higher PHPUnit than version 6, since it was the last version which supported php version I used).
You might ask if it might affect your project, which already relies on the lower version of the library, perhaps there could be some breaking change, but I don't know if there could be some workaround for using one version for dependency and another version for own project.
Edit: I also had to issue a remove composer command for phpunit dependency, otherwise I was not able to increase my phpunit version directly.
You should add the minimum-stability in your composer.json not in the composer.lock. The option exists see https://getcomposer.org/doc/04-schema.md#minimum-stability
i had the error in a symfony4 project with own bundles.
my-foo-bundle dev-master requires ramsey/uuid-doctrine ^1.5 -> satisfiable by ramsey/uuid-doctrine[1.5.0, 1.6.0] but these conflict with your requirements or minimum-stability.
the solution, i search for "ramsey/uuid-doctrine" in my bundles and i found different requirements "ramsey/uuid-doctrine ^1.5" (in my-foo-bundle) and "ramsey/uuid-doctrine dev-master" (in my app-configuration). So i delete the requirement in the app/composer.json.
This worked for me.

How to use the develop branch of Zend Framework 2 over composer?

In an Apigility driven application my composer.json is looking like this:
{
"name": "misc - myproject-api",
"description": "Skeleton Application for Apigility",
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": ">=2.3.2,<3.0.0",
"zfcampus/zf-apigility": "~1.0",
"zfcampus/zf-apigility-documentation": "~1.0",
"zfcampus/zf-development-mode": "~2.0",
"zfcampus/zf-rest": "~1.0-dev",
"zf-commons/zfc-base": "dev-master",
"zendframework/zend-developer-tools": "dev-master",
"doctrine/doctrine-orm-module": "0.8.*"
},
"require-dev": {
"zendframework/zftool": "dev-master",
"zfcampus/zf-apigility-admin": "~1.0",
"zfcampus/zf-apigility-welcome": "~1.0",
"zfcampus/zf-deploy": "~1.0",
"zfr/zfr-cors": "~1.0",
"zend/zend-studio-development-mode": "~1.0"
},
"keywords": [
"api",
"apigility",
"framework",
"zf2"
],
"support": {
"email": "apigility-users#zend.com",
"irc": "irc://irc.freenode.net/apigility",
"source": "https://github.com/zfcampus/zf-apigility-skeleton",
"issues": "https://github.com/zfcampus/zf-apigility-skeleton/issues"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
},
"config": {
"process-timeout": 5000
},
"type": "library",
"license": "BSD-3-Clause",
"homepage": "http://apigility.org/"
}
There is a ZF2 issue (that causes following error: Fatal error: Cannot use object of type Zend\Db\ResultSet\ResultSet as array). It has been fixed, but not merged to the master branch yet.
Since I need it working now, I tried to switch to the develop branch -- updated my composer.json
{
"name": "misc - myproject-api",
"description": "Skeleton Application for Apigility",
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": "dev-develop as dev-master"
...
}
...
}
and executed a composer update:
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating zendframework/zendframework (dev-master de98f63 => dev-develop be0b349)
Checking out be0b3496b73a61a255d05e945b75f6fdf0995c31
Writing lock file
Generating autoload files
Problem: I'm not observing any changes, the code seems still to be loaded from the ZF2 master branch (e.g. my local Zend\Paginator\Adapter\DbSelect has exactly the state of the according class in the master branch).
How to load the ZF2 develop branch?
UPDATE
I've triedthe the composer require direction value for the develop branch (2.4.*#dev) from the Packagist page of the Zend Framework. The result is the same as with dev-develop or dev-develop as dev-master -- the console shows the correct branch (or better the correct commit be0b349) downloading
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing zendframework/zendframework (2.3.4)
- Installing zendframework/zendframework (dev-develop be0b349)
Cloning be0b3496b73a61a255d05e945b75f6fdf0995c31
Writing lock file
Generating autoload files
but after the updating, the code is still like in the master branch.
UPDATE
$ cd [project root directory]/vendor/zendframework/zendframework
$ git status
# On branch develop
nothing to commit (working directory clean)
That means, the branch is correct. And its also up-to-date, since the last commit , git log shows is be0b3496b73a61a255d05e945b75f6fdf0995c31 from 3d of February -- and that is actually the current HEAD revision.
So, the branch is correct, the revision is correct... Why is the code uot-of-date?
The "develop" branch has an alias to be version 2.4. You could require "2.4.*#dev" to get it.
If this breaks some of your dependencies, you could alias this with a 2.3 version.
"zendframework/zendframework": "dev-develop as 2.3.4.1"

Composer dependency without packagist

I have a project that has a dependency to 'webiny/crypt' package (I'm the owner of webiny/crypt repo also https://github.com/Webiny/Crypt).
{
"require": {
"webiny/crypt": "dev-master"
},
"minimum-stability": "dev"
}
Inside composer.json in webiny/crypt repo, I need to define a dependency to this repo: https://github.com/ircmaxell/php-cryptlib
That repo is not available on packagist, but inside its github repo it has a composer.json file.
I tried several solutions, but none of them worked. Here are some examples of what I tried...this is the content of composer.json of webiny/crypt.
Example 1:
"minimum-stability": "dev",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ircmaxell/PHP-CryptLib"
}
],
"require": {
"php": ">=5.4.0",
"webiny/class-loader": "dev-master",
"webiny/config": "dev-master",
"webiny/std-lib": "dev-master",
"ircmaxell/PHP-CryptLib": "*"
}
Example 2:
"minimum-stability": "dev",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ircmaxell/PHP-CryptLib"
}
],
"require": {
"php": ">=5.4.0",
"webiny/class-loader": "dev-master",
"webiny/config": "dev-master",
"webiny/std-lib": "dev-master",
"CryptLib/CryptLib": "*"
}
Also I tried both examples with 'dev-master' version instead of '*' on the CryptLib repo.
From the composer docs # https://getcomposer.org/doc/05-repositories.md#repository
Repositories are only available to the root package and the
repositories defined in your dependencies will not be loaded. Read the
FAQ entry if you want to learn why.
I think your only option, unless you want to tell your users to add that repo too, is to fork https://github.com/ircmaxell/PHP-CryptLib and then publish it to packagist. Maybe drop the author an email regarding this first tho.
Sorry, probably not the answer you were looking for.

ZF2 Modules & external dependencies

I'm not clear on what the best practice is for including external libraries in a custom module that I plan on distributing.
Normally I'd place the external library under the application's vendor directory. But I want to ensure that all dependencies are met when I distribute my custom module (i.e. I don't want to force people to manually download the dependency into their app's vendor directory).
Is the correct practice to include a vendor directory under the module directory as per the the following?
/application_dir
/vendor
/module
/my_module
/vendor
Use composer, you can find documentation here:
Composer Documentation
Basically you would modify the file composer.json in the root of your application and add your dependencies in the require section:
{
"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.2.*",
"doctrine/common": "dev-master",
"zendframework/zendpdf": "2.*",
"zendframework/zendservice-recaptcha": "2.*",
"thiagoalessio/tesseract_ocr": ">= 0.1.2",
"zf-commons/zfc-user": "dev-master"
// add your requirements here**
}
}
if the dependancy is on a private github repository, you can add it like this:
{
"require": {
"vendor/my-private-repo": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "git#bitbucket.org:vendor/my-private-repo.git"
}
]
}
Don't forget to do composer.phar update after your done adding them.

Categories