README.md
1
2# php-psr
3
4[![GitHub Linux Build Status](https://github.com/jbboehr/php-psr/workflows/linux/badge.svg)](https://github.com/jbboehr/php-psr/actions?query=workflow%3Alinux)
5[![GitHub OSX Build Status](https://github.com/jbboehr/php-psr/workflows/osx/badge.svg)](https://github.com/jbboehr/php-psr/actions?query=workflow%3Aosx)
6[![GitHub Windows Build Status](https://github.com/jbboehr/php-psr/workflows/windows/badge.svg)](https://github.com/jbboehr/php-psr/actions?query=workflow%3Awindows)
7[![GitHub Docker Build Status](https://github.com/jbboehr/php-psr/workflows/docker/badge.svg)](https://github.com/jbboehr/php-psr/actions?query=workflow%3Adocker)
8[![Appveyor Build Status][:badge-appveyor:]][:build-appveyor:]
9[![Coverage Status][:badge-coveralls:]][:build-coveralls:]
10[![License][:badge-license:]][:ext-license:]
11
12
13
14This PHP extension provides the interfaces from the [PSR][:psr-fig:] standards as established by the [PHP-FIG][:php-fig:] group.
15You can use interfaces provided by this extension in another extension easily - see this [example][:example:].
16
17## Interfaces
18
19| PSR | Reference | Tested against |
20| --- | --- | --- |
21| [PSR-3][:psr-3:] | [psr/log][:psr-log:] [*](#psrlogunimpl) | [monolog][:monolog:] |
22| [PSR-6][:psr-6:] | [psr/cache][:psr-cache:] | [psx-cache][:psx-cache:] |
23| [PSR-7][:psr-7:] | [psr/http-message][:psr-http-message:] | [laminas-diactoros](https://github.com/laminas/laminas-diactoros) |
24| [PSR-11][:psr-11:] | [psr/container][:psr-container:] | [psx-dependency][:psx-dependency:] |
25| [PSR-13][:psr-13:] | [psr/link][:psr-link:] | [php-fig/link-util][:link-util:] |
26| [PSR-14][:psr-14:] | [psr/event-dispatcher][:psr-event-dispatcher:] | [tukio][:tukio:] |
27| [PSR-15][:psr-15:] | [psr/http-server-handler][:psr-http-server-handler:] | [equip/dispatch][:dispatch:] |
28| [PSR-15][:psr-15:] | [psr/http-server-middleware][:psr-http-server-middleware:] | [middleware/request-handler][:request-handler:] |
29| [PSR-16][:psr-16:] | [psr/simple-cache][:psr-simple-cache:] | [psx-cache][:psx-cache:] |
30| [PSR-17][:psr-17:] | [psr/http-factory][:psr-http-factory:] | [http-interop/http-factory-guzzle][:http-factory-guzzle:] |
31| [PSR-18][:psr-18:] | [psr/http-client][:psr-http-client:] | [ricardofiorani/guzzle-psr18-adapter][:guzzle-psr18-adapter:] |
32
33## Installation
34
35### Linux / macOS
36
37Prerequisite packages are:
38
39- PHP development headers and tools
40- `gcc` >= 4.4 | `clang` >= 3.x | `vc` >= 11
41- GNU `make` >= 3.81
42- `automake`
43- `autoconf`
44
45You 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.
46
47```bash
48git clone https://github.com/jbboehr/php-psr.git
49cd php-psr
50phpize
51./configure
52make
53make test
54sudo make install
55```
56
57If you have specific PHP versions running:
58
59```bash
60git clone https://github.com/jbboehr/php-psr.git
61cd php-psr
62/usr/local/bin/phpize
63./configure --with-php-config=/usr/local/bin/php-config
64make
65make test
66sudo make install
67```
68
69Add the extension to your *php.ini*:
70
71```ini
72echo extension=psr.so | tee -a /path/to/your/php.ini
73```
74
75Finally, _restart the web server_.
76
77### PECL / Windows
78
79You may also be able to install this extension via [PECL][:pecl-psr:]:
80
81```bash
82pecl install psr
83```
84
85or by downloading a DLL from [PECL][:pecl-psr:] or [windows.php.net][:windows-psr:] and placing it in the appropriate directory.
86
87### Nix / NixOS
88
89```bash
90nix-env -i -f https://github.com/jbboehr/php-psr/archive/master.tar.gz
91```
92
93with a custom version of PHP:
94
95```bash
96nix-env -i -f https://github.com/jbboehr/php-psr/archive/master.tar.gz --arg php '(import <nixpkgs> {}).php71'
97```
98
99or, in a `.nix` file:
100
101```nix
102(import <nixpkgs> {}).callPackage (import (fetchTarball {
103 url = https://github.com/jbboehr/php-psr/archive/v1.0.0.tar.gz;
104 sha256 = "12237b392rz224r4d8p6pwnldpl2bfrvpcim5947avjd49sn8ss4";
105})) {}
106```
107
108### Using with composer
109
110In 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.
111
112<a name="psrlogunimpl">Note:</a> `LoggerInterfaceTest` and `TestLogger` from `psr/log` are not implemented. If you use these classes, you should keep `psr/log` installed ([discussion](https://github.com/jbboehr/php-psr/issues/57)).
113
114```json
115{
116 "name": "sample/app",
117 "require": {
118 "ext-psr": "*"
119 },
120 "provide": {
121 "psr/log": "^1",
122 "psr/cache": "^1",
123 "psr/http-message": "^1",
124 "psr/container": "^1",
125 "psr/link": "^1",
126 "psr/event-dispatcher": "^1",
127 "psr/http-server-handler": "^1",
128 "psr/http-server-middleware": "^1",
129 "psr/simple-cache": "^1",
130 "psr/http-factory": "^1",
131 "psr/http-client": "^1"
132 },
133}
134```
135
136This will use this PHP extension instead of downloading from packagist.
137
138## Credits
139
140* [@sergeyklay][:github-sergeyklay:] - Appveyor and documentation improvements
141* [@flyinghail][:github-flyinghail:] - PSR-14, PSR-15, PSR-17, and PSR-18 support
142* [@Jan-E][:github-jan-e:] - Original appveyor template
143* [All Contributors](https://github.com/jbboehr/php-psr/graphs/contributors)
144
145## License
146
147This project is open source software licensed under the Simplified BSD License.
148See the [LICENSE.md][:ext-license:] file for more information.
149
150PSR Interfaces: Copyright (c) 2012-present [PHP Framework Interoperability Group][:php-fig:].
151
152[:psr-fig:]: https://www.php-fig.org/psr
153[:php-fig:]: https://www.php-fig.org
154[:pecl-psr:]: https://pecl.php.net/package/psr
155[:badge-appveyor:]: https://ci.appveyor.com/api/projects/status/x1ymkqggy1mkl0ux/branch/master?svg=true
156[:badge-coveralls:]: https://coveralls.io/repos/jbboehr/php-psr/badge.svg?branch=master&service=github
157[:badge-license:]: https://img.shields.io/badge/license-BSD-brightgreen.svg
158[:build-appveyor:]: https://ci.appveyor.com/project/jbboehr/php-psr/branch/master
159[:build-coveralls:]: https://coveralls.io/github/jbboehr/php-psr?branch=master
160[:ext-license:]: https://github.com/jbboehr/php-psr/blob/master/LICENSE.md
161[:example:]: https://github.com/jbboehr/php-handlebars/blob/v0.7.1/impl.c#L213-L215
162[:psr-3:]: http://www.php-fig.org/psr/psr-3
163[:psr-log:]: https://github.com/php-fig/log
164[:monolog:]: https://github.com/Seldaek/monolog
165[:psr-6:]: https://www.php-fig.org/psr/psr-6
166[:psr-cache:]: https://github.com/php-fig/cache
167[:psx-cache:]: https://github.com/apioo/psx-cache
168[:psr-7:]: https://www.php-fig.org/psr/psr-7
169[:psr-http-message:]: https://github.com/php-fig/http-message
170[:psr-11:]: https://www.php-fig.org/psr/psr-11
171[:psr-container:]: https://github.com/php-fig/container
172[:psx-dependency:]: https://github.com/apioo/psx-dependency
173[:psr-13:]: https://www.php-fig.org/psr/psr-13
174[:psr-link:]: https://github.com/php-fig/link
175[:link-util:]: https://github.com/php-fig/link-util
176[:psr-16:]: https://www.php-fig.org/psr/psr-16
177[:psr-simple-cache:]: https://github.com/php-fig/simple-cache
178[:windows-psr:]: http://windows.php.net/downloads/pecl/releases/psr/
179[:github-sergeyklay:]: https://github.com/sergeyklay
180[:github-jan-e:]: https://github.com/Jan-E
181[:github-flyinghail:]: https://github.com/flyinghail
182[:psr-15:]: http://www.php-fig.org/psr/psr-15
183[:psr-http-server-handler:]: https://github.com/php-fig/http-server-handler
184[:psr-http-server-middleware:]: https://github.com/php-fig/http-server-middleware
185[:dispatch:]: https://github.com/equip/dispatch
186[:request-handler:]: https://github.com/middlewares/request-handler
187[:psr-17:]: https://www.php-fig.org/psr/psr-17
188[:psr-http-factory:]: https://github.com/php-fig/http-factory
189[:http-factory-guzzle:]: https://github.com/http-interop/http-factory-guzzle
190[:psr-18:]: https://www.php-fig.org/psr/psr-18
191[:psr-http-client:]: https://github.com/php-fig/http-client
192[:guzzle-psr18-adapter:]: https://github.com/ricardofiorani/guzzle-psr18-adapter
193[:psr-14:]: http://www.php-fig.org/psr/psr-14
194[:psr-event-dispatcher:]: https://github.com/php-fig/event-dispatcher
195[:tukio:]: https://github.com/Crell/Tukio.git
196