Laravel-5.1 geonames, cloning repository using Composer - github

I want to use geonames for addresses on a website. I'm developing it using Laravel 5.1. I found this useful as a tutorial to get started: Ipalaus Laravel 4.* for Geonames.
Because of its version incompatibility, I contacted a co-worker on the project who redirected me to use his repository: My conversation with Javier Martinz on L-5.1 compatible update. The simple solution was to add his repository which I did in composer.json. After running this I was expecting to have seen the repository cloned and have artisan command for geonames, to my surprise nothing of sort. I am using no version control like git, just storing locally.
How do I clone the repository? I have written him but no response for now. I suppose he's taken a break for the holidays.
This is my composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"laravelcollective/html": "5.1.*",
"laravel/socialite": "^2.0",
"toin0u/geocoder-laravel": "#stable",
"ext-zip": "*",
"illuminate/config": ">=5.1.0",
"illuminate/console": ">=5.1.0",
"illuminate/database": ">=5.1.0",
"illuminate/filesystem": ">=5.1.0",
"illuminate/support": ">=5.1.0",
"symfony/process": "2.7.*",
"guzzle/http": "^3.9",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/JavierMartinz/geonames"
}
],
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
This is the error I got when I added: "ipalaus/geonames": "1.0.*"
C:\Users\ken4ward\Documents\xampp\htdocs\tradersmart>composer update
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing guzzlehttp/psr7 (1.2.1)
- Removing psr/http-message (1.0)
- Removing guzzlehttp/promises (1.0.3)
- Installing guzzlehttp/streams (2.1.0)
Downloading: 100%
- Removing guzzlehttp/guzzle (6.1.1)
- Installing guzzlehttp/guzzle (4.2.3)
Downloading: 100%
- Removing laravel/socialite (v2.0.14)
- Installing laravel/socialite (v2.0.4)
Downloading: 100%
Writing lock file
Generating autoload files
> php artisan optimize
Generating optimized class loader
C:\Users\ken4ward\Documents\xampp\htdocs\tradersmart>composer update
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- ipalaus/geonames v1.0.0 requires illuminate/config 4.2.* -> no matching pa
ckage found.
- ipalaus/geonames v1.0.1 requires illuminate/config 4.2.* -> no matching pa
ckage found.
- ipalaus/geonames v1.0.2 requires illuminate/config 4.2.* -> no matching pa
ckage found.
- ipalaus/geonames v1.0.1 requires illuminate/config 4.2.* -> no matching pa
ckage found.
- ipalaus/geonames v1.0.0 requires illuminate/config 4.2.* -> no matching pa
ckage found.
- Installation request for ipalaus/geonames 1.0.* -> satisfiable by ipalaus/
geonames[v1.0.0, v1.0.1, v1.0.2].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further commo
n problems.

I tried to use ipalaus/geonames also, and it was not so nice. It did not function and the issue tickets I created months ago got no response. So I made my own package which imports much faster than ipalaus/geonames and more complete already. It took 15 hours to import the databases with ipalaus/geonames and it takes merely 30 minutes with my package.

Once I'd seen your composer.json, I wondered if this would just register the Git repo as an available source, but not specifically request it as a dependency. I therefore ran this search and found this blog article.
To summarise what that article says, it says that Git repo dependencies need to use the word dev- followed by the branch name you would like (this is usually master, but can vary). So, in your case, the solution in the require JSON array was:
"ipalaus/geonames": "dev-master"
From the conversation on the pull request, it seems that the change you wanted has now been merged down anyway. So you should now be able to follow these instructions and remove the Git repo:
you should be able to required v2.0 for Laravel 5.1 composer require ~2.0 or v3.0 for Laravel 5.2 composer require ~3.0
If it is the case you can now use the Packagist version, do not feel that your time has been wasted - learning how to use Composer with special requirements (such as repo dependencies) is worthwhile indeed.

Related

Composer conflicts GitHub tag with its commit hash

When I run composer update with lot of packages i get this error:
Problem 1
- Installation request for piwik/piwik dev-2491e6bfcf61984b0f0f3387e1496815e809c6cc -> satisfiable by piwik/piwik[dev-2491e6bfcf61984b0f0f3387e1496815e809c6cc].
- myspace/MyPlugin 2.13.0 requires piwik/piwik >=2.16.0 -> satisfiable by piwik/piwik[2.16.0].
- Can only install one of: piwik/piwik[2.16.0, dev-2491e6bfcf61984b0f0f3387e1496815e809c6cc].
- Installation request for myspace/myplugin 2.13.0 -> satisfiable by myspace/MyPlugin[2.13.0].
The weird thing is that piwik tag 2.16.0 is the exact same commit as dev-2491e6bfcf61984b0f0f3387e1496815e809c6cc. Further more I don't see any dependent composer.json which requires dev-2491e6bfcf61984b0f0f3387e1496815e809c6cc.
This in my main composer.json. Repositories are defined as (https://github.com/myspace/MyPlugin.git is a fake address):
"repositories": {
"myspace-myplugin": {
"type": "vcs",
"url": "https://github.com/myspace/MyPlugin.git"
},
"require": {
"myspace/MyPlugin": "2.13.0"
}
}
and dependent composer.json requirements of myspace/MyPlugin:
"require": {
"piwik/piwik": ">=2.16.0",
"php": ">=5.4"
}
I switched from unbounded version constraint >=2.16.0 to range ^2.16 on piwik/piwik - this will install piwik/piwik (2.16.1-b1) atm.
I've also added minimum-stability beta because piwik 2.16.0 has a dependency on php-di 5.0.0-beta, which could not be resolved at the given level of stability. We need to go lower to get beta stuff. And they should probably raise it to a stable version on their side.
Bottom-line: please try the following composer.json.
{
"require": {
"piwik/piwik": "^2.16",
"php": ">=5.4"
},
"minimum-stability": "beta"
}
Tested & works for me.

How to create older (2.4 not 2.5) ZF2 project with ZFTool

In the current folder I've installed ZFTool
$ cat composer.json
{
"require" : {
"php" : ">=5.3.3",
"zendframework/zftool": "v0.1.0",
"zendframework/zendframework": "2.4.8"
}
}
$ /opt/lampp/bin/php ./vendor/bin/zf.php version
ZFTool - Zend Framework 2 command line Tool
The application in this folder is using Zend Framework 2.4.8
I try
First install ZF2 and later create project
$ /opt/lampp/bin/php ./vendor/bin/zf.php install zf proj000 2.4.8
The ZF library 2.4.8 has been installed in proj000.
$ /opt/lampp/bin/php ./vendor/bin/zf.php create project proj000
The directory proj000 already exists. You cannot create a ZF2 project here.
I got the right library version but cannot create project.
First create project and later install ZF2
$ /opt/lampp/bin/php ./vendor/bin/zf.php create project proj001
sh: 1: php: not found
PHP Warning: copy(/tmp/composer.phar): failed to open stream: No such file or directory in /PATH/vendor/zendframework/zftool/src/ZFTool/Controller/CreateController.php on line 85
Warning: copy(/tmp/composer.phar): failed to open stream: No such file or directory in /PATH/vendor/zendframework/zftool/src/ZFTool/Controller/CreateController.php on line 85
PHP Warning: chmod(): No such file or directory in /PATH/vendor/zendframework/zftool/src/ZFTool/Controller/CreateController.php on line 87
Warning: chmod(): No such file or directory in /PATH/vendor/zendframework/zftool/src/ZFTool/Controller/CreateController.php on line 87
ZF2 skeleton application installed in proj001.
In order to execute the skeleton application you need to install the ZF2 library.
Execute: "composer.phar install" in proj001
For more info in proj001/README.md
$ /opt/lampp/bin/php ./vendor/bin/zf.php install zf proj001 2.4.8
The directory proj001 already exists. You cannot install the ZF2 library here.
When i check proj001/composer.json i see, the ZF 2.5 settings are generated
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.5",
"zendframework/zendframework": "~2.5"
}
}
The ZFTool created project with composer.json adapted for ZF 2.5 not ZF 2.4.
I cannot use it since I've hosting server with PHP 5.4
I came with the following solution.
I change generated proj001/composer.json into 2.4 settings
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.4",
"zendframework/zendframework": "<=2.4.9",
"zendframework/zftool": "*",
"phpunit/phpunit": "4.7"
}
}
Now, php composer.phar install installs older packages like zendframework/zendframework (2.4.9)

Composer package not found in any version

I am trying to create a custom vendor package but have not yet put the package on packagist. According to the docs, the package can be loaded from git (vcs) instead of packagist: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
The yii2 project (although don't think framework matters) I have created package inside vendor folder:
foundationize/yii2-foundation
(folder structure is as above, I have quadruple-checked).
My root public_html/composer.json has following entries:
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-swiftmailer": "*",
"foundationize/yii2-foundation": "dev-master"
},
My package composer file, vendor/foundationize/yii2-foundation/composer.json looks like:
{
"name": "foundationize/yii2-foundation",
"description": "The Foundation extension for the Yii2 framework",
"keywords": ["yii2", "foundation"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/foundationize/yii2-foundation/issues",
"wiki": "https://github.com/foundationize/yii2-foundation/wiki",
"source": "https://github.com/foundationize/yii2-foundation.git"
},
"authors": [
{
"name": "gvanto",
"email": "gvanto#hotmail.com",
"homepage": "http://foundationize.com"
}
],
"require": {
"yiisoft/yii2": "*"
},
"autoload": {
"psr-4": {
"foundationize\\foundation\\": ""
}
},
"repositories": [
{
"packagist": false,
"type": "vcs",
"url": "https://github.com/foundationize/yii2-foundation.git"
}
]
}
When I run composer install (or update), I keep getting error below:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- The requested package foundationize/yii2-foundation could not be found in any version, there may be a typo in the package name.
Potential causes:
A typo in the package name
The package is not available in a stable-enough version according to your minimum-stability setting see
https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion
for more details.
Read https://getcomposer.org/doc/articles/troubleshooting.md for
further common problems.
I have googled it high and low, read the docs can't seem to get it to work (always the same error, which I actually think would be more useful if it said either the package was not found OR the incorrect package version was found).
You have to add the repositories entry to your root composer.json file. Otherwise, Composer does not know where to search for your package.
Had a similar problem to this and it was because I was running composer in the /web directory in the new Drupal structure. When I ran it in the root all was fine. Annoyingly, you need to run Drush in /web
Since Laravel version 5.5 there is a Package Auto-Discovery feature, so there is no need to add service provider. All you need to register package like this:
composer require barryvdh/laravel-debugbar:dev-master
You can find more info in these articles:
https://medium.com/#taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518
https://divinglaravel.com/laravels-package-auto-discovery

Installing repo from GitHub with composer

I'm trying to update this test extension to my project but I encountered an error:
adz#adz:/var/www/site$ php composer.phar update
Loading composer repositories with package information Updating
dependencies (including require-dev)
Nothing to install or update
I also tried
adz#adz:/var/www/site$ php composer.phar require adz/yii2-featureditems:dev-master
./composer.json has been updated
Package "adz/yii2-featureditems" listed for update is not installed.
Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Here is my composer.json file
{
"repositories":[
{
"type": "git",
"url": "https://github.com/adzayko/featured-items.git"
}
],
"require": {
"adz/yii2-featureditems": "dev-master"
}
}

How to install ZendRest module in zf2?

I would like to install the ZF2 ZendRest module.
How to install it?
When I'm doing
php .\composer.phar install
in \vendor\zendrest. I get:
Loading composer repositories with package information
Installing dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package zendframework/zend-http 1.0.0 could not be found.
Problem 2
- The requested package zendframework/zend-uri 1.0.0 could not be found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum- stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Where should I put the ZendRest folder?
Thanks!
There is no stable version for the ZendRest dependencies: zend-http and zend-uri (see the show output below for the existing versions). Composer relies on stable packages by default. That's why you can't install this package.
$ composer show zendframework/zend-http
name : zendframework/zend-http
descrip. : provides an easy interface for preforming Hyper-Text Transfer Protocol (HTTP) requests
keywords : zf2, http
versions : 2.0.0rc4, 2.0.0rc3, 2.0.0rc2, 2.0.0-rc1, 2.0.0-beta5, 2.0.0-beta4
type : library
...
You should change the minimum-stability to dev in your project:
{
"require": {
// ...
},
"minimum-stability": "dev"
}
Edit: the following composer.json works for instance. This is what you should have in your own project (maybe with more dependencies):
{
"require": {
"zendframework/zend-rest": "*"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"minimum-stability": "dev"
}