加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 从GitLab安装自定义编译器包

发布时间:2020-12-13 22:26:08 所属栏目:PHP教程 来源:网络整理
导读:我创建了一个简单的测试wordpress插件.该插件由一个php文件(kreplach.php)和一个composer.json组成: kreplach.php ?php /* Plugin Name: kreplach Plugin URI: http://gitlab.example.com/sales/kreplach Description: just a test Author: Foo Bartok Vers
我创建了一个简单的测试wordpress插件.该插件由一个php文件(kreplach.php)和一个composer.json组成:

kreplach.php

<?php
    /*
    Plugin Name: kreplach
    Plugin URI: http://gitlab.example.com/sales/kreplach
    Description: just a test
    Author: Foo Bartok
    Version: 1.0
    Author URI: http://example.com
    */
?>

composer.json

{
    "license": "MIT","name": "sales/kreplach","type": "wordpress-plugin","description": "just a test","authors": [
        {
            "name": "Foo Bartok","email": "foo@example.com","homepage": "example.com"
        }
    ],"require": {
        "composer/installers": "*"
    }
}

在我的开发服务器上,我有以下composer.json

服务器的composer.json

{
    "repositories": [
        {
            "type": "composer","url": "https://wpackagist.org"
        },{
            "type": "vcs","url": "git@gitlab.example.com:sales/kreplach.git"
        }
    ],"require": {
        "php": ">=5.4","wpackagist-plugin/akismet": "*","wpackagist-plugin/contact-form-7": "*","wpackagist-plugin/wordpress-importer": "*","sales/kreplach": "master","johnpbloch/wordpress": "4.*","composer/installers": "*"
    },"extra": {
        "wordpress-install-dir": "wp"
    }
}

我认为应该发生什么:

> Composer查看composer.json的git repo
> Composer匹配构建主机的composer.json中的名称“sales / kreplach”
> Composer将主分支的内容复制到构建主机上的wp-content / plugins / kreplach中.
>我的假插件没有做任何设计.

实际发生了什么:

苦,苦的失败.

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
    - The requested package sales/kreplach 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://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

我已经测试了将sales / kreplach repo克隆到我试图安装插件的同一主机上.

为了确保作曲家实际上正在从git repo中读取composer.json文件,我引入了一个拼写错误(是的,完全是故意的,就像),它抛出一个“嘿,这个json文件坏了,泡沫头”错误.

我的gitlab版本是omnibus edition 8.6.4(今天安装).

我用pip / requirements.txt成功完成了同样的技巧来安装自定义python模块,所以我不习惯按照说明操作.我错过了一个步骤,或某种非显而易见的(至少对我来说)命名法吗?

解决方法

我没有使用过gitlab,但是在Bitbucket和GitHub中使用了这个方法.

您需要在服务器的composer.json中指定“sales / kreplach”:“dev-master” – 请注意,分支名称必须以“dev-”为前缀.

显然,Composer对GitHub和BitBucket有特别的支持,Gitlab可能不存在…所以你may need to specify git as the repository type而不是vcs.

祝好运!

参考文献:

> https://lornajane.net/posts/2014/use-a-github-branch-as-a-composer-dependency
> https://getcomposer.org/doc/05-repositories.md#vcs
> https://getcomposer.org/doc/05-repositories.md#git-alternatives

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读