【问题标题】:Laravel-5.1 geonames, cloning repository using ComposerLaravel-5.1 地理名称,使用 Composer 克隆存储库
【发布时间】:2016-04-06 12:14:02
【问题描述】:

我想在网站上使用地名作为地址。我正在使用 Laravel 5.1 开发它。我发现这作为入门教程很有用:Ipalaus Laravel 4.* for Geonames

由于其版本不兼容,我联系了该项目的一位同事,他将我重定向到使用他的存储库:My conversation with Javier Martinz on L-5.1 compatible update。简单的解决方案是添加我在composer.json 中所做的他的存储库。运行此程序后,我希望看到存储库被克隆并拥有artisan 地理名称命令,令我惊讶的是没有任何结果。我没有使用 git 之类的版本控制,只是在本地存储。

如何克隆存储库?我已经给他写信了,但现在没有回复。我想他假期休息了。

这是我的 composer.json 文件

{
    "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"
    }
}

这是我添加时遇到的错误:"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.

【问题讨论】:

  • IMO 没有足够的细节来说明你做了什么,或者没有发生什么,无法回答这个问题。更新 JSON 文件后是否运行 composer update?发生了什么? vendors 文件夹中是否出现了新的依赖项? Geonames dep 是否需要以某种方式连接到 Laravel 才能出现在 Artisan 命令中?
  • (顺便提一下,针对 Stack Overflow 上的志愿者或 GitHub 上的 F/OSS 项目的紧急请求可能会适得其反 - 我建议您在雇用某人时保存这些请求!此外,拉取请求不是请求支持帮助的合适论坛 - PR 用于与提议的更改相关的对话。)
  • 你读过the documentation吗?它展示了如何通过 Composer 进行更新,以及如何使用提供者注册来设置插件。只需按照 Javier 的说明更改您的依赖项即可。
  • 按照 Javier Martinz 的建议添加存储库后,我确实运行了 composer update,但在我的供应商文件夹中没有反映与地名有关的任何内容。有什么建议吗?谢谢。欣赏。
  • 你会添加这个作为答案,以便为此获得分数吗?欣赏。

标签: github repository composer-php laravel-5.1 geonames


【解决方案1】:

我也尝试使用 ipalaus/geonames,但效果不太好。它不起作用,我几个月前创建的问题单没有得到回应。所以我制作了my own package,它的导入速度比ipalaus/geonames 快得多,而且已经更完整了。用 ipalaus/geonames 导入数据库需要 15 个小时,而我的包只需要 30 分钟。

【讨论】:

  • 非常易于使用。感谢您的好意。
  • Evren,您的更改是否可以合并回原始项目,或者您的更改本质上是一个分支?
  • @halfer 我是从头开始写的,所以它不能被合并,它不是一个分叉。我无法让 ipalaus/geonames 发挥作用,并且作者从未回复我的问题报告。相反,另一个有同样问题的人做出了回应(但因为他也切换到了我的地名导入器)-> github.com/ipalaus/geonames/issues/30
  • 好吧,我猜如果原作者在 GitHub 上没有回复,可能会被放弃。干得好:-).
【解决方案2】:

看到您的composer.json 后,我想知道这是否只是将 Git 存储库注册为可用源,而不是专门将其请求为依赖项。因此我ran this search 找到了this blog article

总结那篇文章的内容,它说 Git 存储库依赖项需要使用单词 dev- 后跟您想要的分支名称(这通常是 master,但可能会有所不同)。因此,在您的情况下,require JSON 数组中的解决方案是:

"ipalaus/geonames": "dev-master"

从关于拉取请求的对话来看,您想要的更改现在似乎已经被合并了。因此,您现在应该能够按照这些说明删除 Git 存储库了:

您应该能够为 Laravel 5.1 作曲家要求 v2.0 或为 Laravel 5.2 作曲家要求 ~2.0 或 v3.0 作曲家要求 ~3.0

如果你现在可以使用 Packagist 版本,不要觉得你的时间被浪费了——学习如何使用 Composer 有特殊要求(例如 repo 依赖)确实是值得的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 2020-01-13
    • 2021-11-18
    相关资源
    最近更新 更多