使用国内镜像
打开命令行窗口(windows用户)或控制台(Linux、Mac 用户)并执行如下命令:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
发布自己的package
1.在github上创建自己的项目,例如:helloworld
2.将项目通过git克隆到本地,创建composer.json
3.commit并push到github上
4.到https://packagist.org/ 上点击右上角”submit package”,需要登录,点击”login with github”使用github账号登录即可,初次登录会让你登记邮箱,完了再次点击”submit package”。
5.填写项目地址”Repository URL”,这个url就是你github上helloworld项目的url。
6.点击”check”按钮,系统自动检测你的项目中composer.json是否合格,并给出原因。如果没有错误的话,请点击提交。
7.包创建成功,可以根据提示继续配置github自动同步功能,这样每次push后,packagist对应包的版本号也会更新。
8.修改包并更新,修改后git push,然后到使用该包的项目中执行composer –dev –prefer-source update [包名] ,加–prefer-source意思是从github上检出最新版本。
个人项目中使用composer
我们这里建议一个项目demo, 然后我们在demo目录下执行:
composer require illuminate/database:~4.2
那么你应该会看到:
Using version ~4.2 for illuminate/database
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing nesbot/carbon (1.13.0)
Loading from cache
- Installing illuminate/support (v4.2.9)
Downloading: 100%
Downloading: 100%
Downloading: 100%
Failed, trying the next URL
Downloading: 100%
- Installing illuminate/container (v4.2.9)
Downloading: 100%
- Installing illuminate/events (v4.2.9)
Downloading: 100%
- Installing illuminate/database (v4.2.9)
Downloading: 100%
Writing lock file
Generating autoload files
这样就表示Eloquent已经安装好了。
配置
下面我们来配置Eloquent。
首先我们创建一个入口文件,如果你的项目已经有内容,那么同理在你的项目入口文件加入即可:
demo/start.php:
<?php
// 载入composer的autoload文件
include __DIR__ . '/vendor/autoload.php';
然后我们加入数据库配置:
$database = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'demo',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
];
上面我们的数据库配置,库名demo,用户名root,密码为空,这个demo是我在mysql里建立好的空数据库。
然后我们加入Eloquent初始化代码:
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
// 创建链接
$capsule->addConnection($database);
// 设置全局静态可访问
$capsule->setAsGlobal();
// 启动Eloquent
$capsule->bootEloquent();
那么Eloquent就配置完成了。
解决一下问题:
Cannot adopt OID in SQUID-MIB: cacheClients ::= { cacheProtoAggregateStats 15 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendLineIndex ::= { nsExtendOutput2Entry 1 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutLine ::= { nsExtendOutput2Entry 2 }
Cannot adopt OID in UCD-SNMP-MIB: laIndex ::= { laEntry 1 }
Cannot adopt OID in UCD-SNMP-MIB: laNames ::= { laEntry 2 }
Cannot adopt OID in UCD-SNMP-MIB: laLoad ::= { laEntry 3 }
Cannot adopt OID in UCD-SNMP-MIB: laConfig ::= { laEntry 4 }
Cannot adopt OID in UCD-SNMP-MIB: laLoadInt ::= { laEntry 5 }
Cannot adopt OID in UCD-SNMP-MIB: laLoadFloat ::= { laEntry 6 }
Cannot adopt OID in UCD-SNMP-MIB: laErrorFlag ::= { laEntry 100 }
Cannot adopt OID in UCD-SNMP-MIB: laErrMessage ::= { laEntry 101 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyRestart ::= { netSnmpNotifications 3 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyShutdown ::= { netSnmpNotifications 2 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyStart ::= { netSnmpNotifications 1 }
sudo apt-get install snmp-mibs-downloader
sudo apt-get update