2018年12月17日14:32:05

因为要做搜索,所以需要用分词工具php的分词不借助的第三方的真的很少,

目前选择的是 http://www.phpbone.com/phpanalysis/

但是这个插件没有放上github,虽然有些同学自己搬到了github上但是都有一些封装,但是不是原生直接搬过去的

1,先注册github

创建  Create a new repository   https://github.com/new 注意要是公开,注意不要使用下划线,中划线等非字母数字,防止后面读取composer.json 时候名字不一致,可能出现加载不了

举例: https://github.com/zh7314/phpanalysis

2,连接github项目关联本地代码项目

参考:https://www.cnblogs.com/ttjsndx/p/7943444.html

在本机上设置你的github的邮箱和用户名

git config --global user.name "用户名"
git config --global user.email "邮箱"

ssh-keygen -t rsa -C "邮箱"

根据提示,按三次回车键,最后会生成ssh key值,并告诉你key值存放的文件的位置,找到该文件并复制ssh key

记住你存放.ssh 的位置,找到找有 id_rsa.pub  可能因为系统原因这个文件名会不同

打开你的github主页。找到Settings,

打开你的github主页。找到Settings,选择SSH and GPG keys ,再选择new SSH key,title 随意填,key值就是刚刚生成的本机 SSH KEY

打开github主页,选择 new repository,打开新建项目页面。   

在新建项目页面,输入项目名称,点击下一步,复制生成项目后的项目SSH   

2.打开本地仓库的git bash页面。输入 git remote add origin "项目SSH"    

3.先同步github上master分支的代码,再指定上传的默认分支 git pull origin master git push -u origin master   

第三步设置了本地仓库对应的是github账户上的哪一个项目,并且设置了代码上传的分支。

注意github上的项目名称与本地仓库名称同级,也就是说,从github上同步代码时,只会更新项目名称下的各个文件到本地仓库中。

3,登录https://packagist.org/ 用github账号登录,然后直接点 submit  填写github的url 例如 https://github.com/zh7314/phpanalysis.git  这个是我刚弄好的

如果你github有更新代码请 update 更新

到了具体包的页面例如 https://packagist.org/packages/zh7314/phpanalysis

composer require zh7314/phpanalysis dev-master   就可以直接下载包,注意包的版本,我这边写 dev

官方文档: https://git-scm.com/book/zh/v2

git常用命令

代码里面需要创建 新的代码包里面 composer.json,这个是必须

例:

{
"name": "zh7314/phpanalysis", //这个是 Packages的名称注意,这个不是repository   的名称,最好一直
"description": "phpanalysis中文分词",
"type": "library",
"licence": "MIT",
"require": {
"php": ">=5.6.5" //php版本
},
"autoload": {
"psr-4": {
"zh7314\\": "./" 目录全部加载,也可以指定某个目录的源码
},
"files": [
]
},
"minimum-stability": "dev" //最小稳定版本
}

最好放一个autoloader自动加载

<?php

namespace phpspider;

/**
* autoloader.
*/
class autoloader
{
/**
* Autoload root path.
*
* @var string
*/
protected static $_autoload_root_path = ''; /**
* Set autoload root path.
*
* @param string $root_path
* @return void
*/
public static function set_root_path($root_path)
{
self::$_autoload_root_path = $root_path;
} /**
* Load files by namespace.
*
* @param string $name
* @return boolean
*/
public static function load_by_namespace($name)
{
$class_path = str_replace('\\', DIRECTORY_SEPARATOR, $name); if (strpos($name, 'zh7314\\') === 0)
{
$class_file = __DIR__ . substr($class_path, strlen('zh7314')) . '.php';
}
else
{
if (self::$_autoload_root_path)
{
$class_file = self::$_autoload_root_path . DIRECTORY_SEPARATOR . $class_path . '.php';
}
if (empty($class_file) || !is_file($class_file))
{
$class_file = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . "$class_path.php";
}
} if (is_file($class_file))
{
require_once($class_file);
if (class_exists($name, false))
{
return true;
}
}
return false;
}
} spl_autoload_register('\zh7314\autoloader::load_by_namespace');

github=>git=>composer Packages 使用教程的更多相关文章

  1. GitBook是一个命令行工具(Node.js库),我们可以借用该工具使用Github/Git和Markdown来制作精美的图书,但它并不是一本关于Git的教程哟。

    GitBook是一个命令行工具(Node.js库),我们可以借用该工具使用Github/Git和Markdown来制作精美的图书,但它并不是一本关于Git的教程哟. 支持输出多种格式 GitBook支 ...

  2. Git连接github以及gitee等使用教程

    Git连接github以及gitee等使用教程 一.初始化本次仓库 在想要放置仓库的文件夹出git bash输入命令 git init 二.生成ssh 在github或者gitee注册账户, 在本地生 ...

  3. Github for Windows使用图文教程_西西软件资讯

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

  4. git常用命令说明教程

    git常用命令说明教程 git介绍 是一个分布式的,版本控制软件.每台使用git的电脑都是一个分版本库.svn是集中管理的. 安装git 一 git相关操作 1.官网下载最新版安装https://gi ...

  5. Git 安装和使用教程

    Git 安装和使用教程 git 提交 全部文件 git add .  git add xx命令可以将xx文件添加到暂存区,如果有很多改动可以通过 git add -A .来一次添加所有改变的文件.注意 ...

  6. Hexo+Github博客最简教程-Dockerfile自动搭建

    闲谈 拿出你的气质,打开你的电脑,借你半小时搭建好属于你的hexo博客,小生用dockerfile自动帮你搭建好:你只需要在你的mac或linux或windows上提前把docker安装好,如何安装不 ...

  7. Git入门基础详情教程

    前言 写了一篇文章<一篇文章了解Github和Git教程>还觉得不错,继续写了<为了Github默默付出,我想了解你>,那么继续写Git 基础知识. Git 官网:https: ...

  8. IDEA内置git功能的使用教程

    IDEA内置git功能的使用教程 IDEA git  IDEA被公认为是最好的java开发工具,除了在代码助手.代码提示.重构工具等方面有比较好的支持,还在各类版本控制工具(git.tfs.svn.g ...

  9. Git 安装和使用教程(更加详细)

    转载至:https://www.cnblogs.com/smuxiaolei/p/7484678.html#undefined Git 安装和使用教程 git 提交 全部文件 git add .  g ...

随机推荐

  1. SpringBoot之解决云服务器VPS在所处云端集群的内网不能解析域名的问题:java.net.UnknownHostException:abc.cn: Temporary failure in name resolution

    一.起因与原因分析过程 前端小伙伴儿告诉我,说服务器崩了. 请求数据接口,接口有响应,但报的json提示指向:数据库异常错误. 遂登陆云主机查看日志,核心记录显示如下: 2018-11-09 22:1 ...

  2. nnet3配置中的“编译”

    编译概述 编译流程将Nnet和ComputationRequest作为输入,输出NnetComputation.ComputationRequest包含可用的输入索引 以及 请求的输出索引. 不提供输 ...

  3. 使用Roslyn编译项目的示例

    using System; using System.Collections.Generic; using System.IO; using Microsoft.CodeAnalysis; using ...

  4. c#管理文件系统

    using System; using System.Collections.Generic; using System.IO; using static System.Console; /*Syst ...

  5. 【转】利用apktool反编译apk,并且重新签名打包

    网站:https://ibotpeaches.github.io/Apktool,下载安装好apktool. 我的安装在 C:\Users\Administrator\Downloads\apktoo ...

  6. bootstrap的tree控件

    地址:http://runjs.cn/detail/xtte94ls http://runjs.cn/code/xtte94ls

  7. zabbix3.2监控rabbitmq集群

    监控模板和脚本github地址:https://github.com/jasonmcintosh/rabbitmq-zabbix/tree/master/scripts/rabbitmq .将rabb ...

  8. ASP.NET 多环境下配置文件web.config的灵活配置

    调试,发布Asp.net程序的时候,开发环境和发布环境的Web.Config往往不同,比如connectionstring等.如果常常有调试,发布的需求,就需要常常修改web.config文件,这往往 ...

  9. RabbitMQ 学习日记

    RabbitMQ三种Exchange模式(fanout,direct,topic)的性能比较 http://www.rabbitmq.com/tutorials/tutorial-one-dotnet ...

  10. vue在jsx中使用for循环

    return <div domPropsInnerHTML="titles" style={{ color: 'red', fontSize: '14px' }}> { ...