作为程序员一定要保持良好的睡眠,才能好编程

yaf第三课 支持composer怎么做到的?

发布时间:2018-06-05


yaf 是C扩展的一个php框架,有很多的功能没有集成,就需要我们自己去集成这些功能。


composer是php资源仓库,可以直接使用composer中的资源包来扩充我们的功能,从而提高开发效率。


好了,看看composer是如何集成到yaf框架中的。


composer官网:https://pkg.phpcomposer.com/

中国站:https://www.phpcomposer.com



例如:

我本地目录  在  G:/phpstudy/www/testcomposer/ 目录下


https://getcomposer.org/download/


打开这个地址,按照要求,下载composer


设置中国镜像:https://pkg.phpcomposer.com/#how-to-use-packagist-mirror


打开网址如上。

下载安装文件 composer-setup.php


校验成功


开始安装


安装成功,删除composer-setup.php





引入medoo数据库


composer7.png

安装成功后的结果




数据库model类 php

Medoo.txt




命令执行过程:

G:\phpstudy\WWW\testcomposer>php -r "copy('https://getcomposer.org/installer', '
composer-setup.php');"

G:\phpstudy\WWW\testcomposer>dir
 Volume in drive G is 文档
 Volume Serial Number is 0006-C1A8

 Directory of G:\phpstudy\WWW\testcomposer

2018/06/05  08:21    <DIR>          .
2018/06/05  08:21    <DIR>          ..
2018/06/05  08:21           305,459 composer-setup.php
               1 File(s)        305,459 bytes
               2 Dir(s)  44,330,139,648 bytes free

G:\phpstudy\WWW\testcomposer>php -r "if (hash_file('SHA384', 'composer-setup.php
') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a8
58088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer
 corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified

G:\phpstudy\WWW\testcomposer>php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 1.6.5) successfully installed to: G:\phpstudy\WWW\testcomposer
\composer.phar
Use it: php composer.phar


G:\phpstudy\WWW\testcomposer>dir
 Volume in drive G is 文档
 Volume Serial Number is 0006-C1A8

 Directory of G:\phpstudy\WWW\testcomposer

2018/06/05  08:22    <DIR>          .
2018/06/05  08:22    <DIR>          ..
2018/06/05  08:21           305,459 composer-setup.php
2018/06/05  08:22         1,849,094 composer.phar
               2 File(s)      2,154,553 bytes
               2 Dir(s)  44,328,288,256 bytes free

G:\phpstudy\WWW\testcomposer>php -r "unlink('composer-setup.php');"

G:\phpstudy\WWW\testcomposer>dir
 Volume in drive G is 文档
 Volume Serial Number is 0006-C1A8

 Directory of G:\phpstudy\WWW\testcomposer

2018/06/05  08:22    <DIR>          .
2018/06/05  08:22    <DIR>          ..
2018/06/05  08:22         1,849,094 composer.phar
               1 File(s)      1,849,094 bytes
               2 Dir(s)  44,328,595,456 bytes free

G:\phpstudy\WWW\testcomposer>php composer.phar config -g repo.packagist composer
 https://packagist.phpcomposer.com
 


G:\phpstudy\WWW\testcomposer>php composer.phar require catfan/Medoo
Using version ^1.5 for catfan/medoo
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing catfan/medoo (v1.5.6): Downloading (100%)
catfan/medoo suggests installing ext-pdo_sqlsrv (For MSSQL database)
catfan/medoo suggests installing ext-pdo_dblib (For MSSQL or Sybase database on
Linux/UNIX platform)
catfan/medoo suggests installing ext-pdo_oci (For Oracle database)
catfan/medoo suggests installing ext-pdo_oci8 (For Oracle version 8 database)
catfan/medoo suggests installing ext-pdo_pqsql (For PostgreSQL database)
Writing lock file
Generating autoload files

G:\phpstudy\WWW\testcomposer>dir
 Volume in drive G is 文档
 Volume Serial Number is 0006-C1A8

 Directory of G:\phpstudy\WWW\testcomposer

2018/06/05  08:27    <DIR>          .
2018/06/05  08:27    <DIR>          ..
2018/06/05  08:27                58 composer.json
2018/06/05  08:27             2,661 composer.lock
2018/06/05  08:22         1,849,094 composer.phar
2018/06/05  08:27    <DIR>          vendor
               3 File(s)      1,851,813 bytes
               3 Dir(s)  44,328,497,152 bytes free

G:\phpstudy\WWW\testcomposer>