• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Bush-hb
博客园    首页    新随笔    联系   管理    订阅  订阅
使用Github Composer Packagist编写及发布扩展包

  1.在github中创建自己的仓库,然后本地clone,初始化composer init ,在composer.json中增加autoload

 "autoload": {
        "psr-4": { "hubo123\\test\\": "src" }
    }
,hubo123/test目下创建src目录,增加Hello.php文件。
<?php
namespace Hubo123\Demo;

class Hello
{
    private $name;

    public function __construct( $name = 'World' )
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }

    public function hello()
    {
        return 'Hello '.$this->name.'!';
    }
}
 

 ,然后提交到远程仓库.

 

2. 进入packagist官网,进行submit验证,填写仓库的地址进行check.

 

3.点击进入仓库,点击settings->Integrations&services->add service 搜索packagist,然后填写用户名,以及token(此处的token是packagist上的profile菜单下)。

4.项目根目录创建test.php文件,

require_once "vendor/autoload.php";

$hello = new Hubo123\Demo\Hello();
echo $hello->hello();

echo "\n";
$hiGirl = new Hubo123\Demo\Hello('My Goddess');
echo $hiGirl->hello();

 

posted on 2017-04-21 11:26  Bush-hb  阅读(1235)  评论(1)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3