vim php psr,行者无疆

该博文介绍了如何在Linux/macOS和Windows上安装PHP PSR扩展,包括通过phpize、PECL以及Nix/NixOS的方法。此外,还提到了如何在Composer项目中配置以避免不必要的包安装,并提供了关于使用此扩展的注意事项和接口版权信息。
摘要由CSDN通过智能技术生成

php-psr

php-psr.svg?branch=master

master?svg=true

badge.svg?branch=master&service=github

license-BSD-brightgreen.svg

This PHP extension provides the interfaces from the PSR standards as established by the PHP-FIG group.

You can use interfaces provided by this extension in another extension easily - see this example.

Interfaces

Installation

Linux / macOS

Prerequisite packages are:

PHP development headers and tools

gcc >= 4.4 | clang >= 3.x | vc >= 11

GNU make >= 3.81

automake

autoconf

You will need the PHP development headers. If PHP was manually installed, these should be available by default. Otherwise, you will need to fetch them from a repository.

git clone https://github.com/jbboehr/php-psr.git

cdphp-psr

phpize

./configure

make

make test

sudomake install

If you have specific PHP versions running:

git clone https://github.com/jbboehr/php-psr.git

cdphp-psr

/usr/local/bin/phpize

./configure --with-php-config=/usr/local/bin/php-config

make

make test

sudomake install

Add the extension to your php.ini:

echo extension=psr.so | tee -a /path/to/your/php.ini

Finally, restart the web server.

PECL / Windows

You may also be able to install this extension via PECL:

pecl installpsr

or by downloading a DLL from PECL or windows.php.net and placing it in the appropriate directory.

Nix / NixOS

nix-env -i -f https://github.com/jbboehr/php-psr/archive/master.tar.gz

with a custom version of PHP:

nix-env -i -f https://github.com/jbboehr/php-psr/archive/master.tar.gz --arg php '(import {}).php71'

or, in a .nix file:

(import {}).callPackage (import (fetchTarball {

url = https://github.com/jbboehr/php-psr/archive/v1.0.0.tar.gz;

sha256 = "12237b392rz224r4d8p6pwnldpl2bfrvpcim5947avjd49sn8ss4";

})) {}

Using with composer

In your project, you can prevent the installation of the unnecessary composer packages provided by this extension by adding the following to your composer.json. You will need to make sure the extension is installed and enabled in your PHP configuration. You may also want to consider leaving them installed to provide stubs to your IDE. This configuration is not suitable for a library published to packagist.

Note: LoggerInterfaceTest and TestLogger from psr/log are not implemented. If you use these classes, you should keep psr/log installed (discussion).

{

"name":"sample/app",

"require":{

"ext-psr":"*"

},

"provide":{

"psr/log":"^1",

"psr/cache":"^1",

"psr/http-message":"^1",

"psr/container":"^1",

"psr/link":"^1",

"psr/event-dispatcher":"^1",

"psr/http-server-handler":"^1",

"psr/http-server-middleware":"^1",

"psr/simple-cache":"^1",

"psr/http-factory":"^1",

"psr/http-client":"^1"

},

}

This will use this PHP extension instead of downloading from packagist.

Credits

@sergeyklay - Appveyor and documentation improvements

@flyinghail - PSR-14, PSR-15, PSR-17, and PSR-18 support

@Jan-E - Original appveyor template

License

This project is open source software licensed under the Simplified BSD License.

See the LICENSE.md file for more information.

PSR Interfaces: Copyright (c) 2012-present PHP Framework Interoperability Group.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值