You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-11
Original file line number
Diff line number
Diff line change
@@ -2,26 +2,26 @@
2
2
3
3
This project provides a PHP extension implementing bindings for [`libgit2`](https://github.com/libgit2/libgit2). You can use this library to build native Git tooling directly into your PHP application.
4
4
5
-
This branch targets PHP 8. See other branches for other PHP major versions. Please note that this project no longer supports versions before PHP 7.
6
-
7
-
> Note: At this time, PHP 8 support is experimental.
5
+
This branch targets PHP 8. See other branches for other PHP major versions. Please note that this project no longer supports versions before PHP 8.
8
6
9
7
Primary author:
10
8
11
9
> [Roger Gee](https://github.com/RogerGee)
12
10
13
11
## Versioning
14
12
15
-
Since we do not bundle the `libgit2` dependency, it's up to the user to provide the correct version of `libgit2` when building the extension. The `libgit2` version corresponds indirectly to the version of `php-git2` being built. Consult the following table to determine the correct version of `libgit2` required by `php-git2`:
13
+
Since we do not bundle the `libgit2` dependency, it's up to the user to provide the correct version of `libgit2` when building (and running) the extension. The `libgit2` version corresponds indirectly to the version of `php-git2` being built. Consult the following table to determine the correct version of `libgit2` required by `php-git2`:
16
14
17
15
|`php-git2`|`libgit2`| Notes |
18
16
| -------- | ------- | ------- |
19
-
|`2.0.0`|`^1.5.0`|`libgit2` API is now stable |
20
-
|`1.0.0`|`0.25.1`|`libgit2` is unstable, so `v1` exclusively uses `0.25.1`|
17
+
|**`2.0.0`**|`^1.5.0`|`libgit2` API is now stable |
18
+
|`1.0.0`|`0.25.1`|`libgit2` is unstable, so `php-git2@^1.0.0` exclusively uses `0.25.1`|
21
19
22
20
The entries in the table above denote the `libgit2` version requirement for a particular `php-git2` release. An entry is only added when a new version of `libgit2` is required.
23
21
24
-
In theory, you should be able to use any version that fits the constraint (and possibly some previous `libgit2` releases within the same major version). The minimum `libgit2` version denoted by the constraint is the one we use to develop and test the release.
22
+
In theory, you should be able to use any version that fits the constraint. The minimum `libgit2` version denoted by the constraint is the one we use to develop and test the corresponding release.
23
+
24
+
The `php-git2` version corresponds directly to the interfaces and bindings implemented by the extension. Semantic versioning is employed to allow an application to target a correct constraint in its `composer.json` file.
25
25
26
26
### Branches
27
27
@@ -43,11 +43,12 @@ Our core design principle is to follow the original, `libgit2` C API as closely
43
43
44
44
- Most of the opaque `libgit2` data types (i.e. handles) are implemented as resources in PHP userspace:
45
45
- This allows the PHP API to closely follow the underlying C API.
46
+
- (Note that in the next major version of this project, we plan to convert all resources to opaque classes. [This seems to be the trend](https://php.watch/articles/resource-object) in other PHP extensions, and it may be that resource types will be deprecated/removed in future versions of PHP.)
46
47
- Functions that return a `libgit2` handle via an output parameter in the C API return a resource via the function return value in the PHP API:
47
48
- (e.g. `git_repository_open()` returns a `git_repository` resource).
48
49
- Errors are always converted into PHP exceptions
49
-
- Custom interface data structures (e.g. backends) are implemented as PHP classes:
50
-
- This allows the developer to implement a subclass that easily implements a custom interface.
50
+
- Custom data structures (e.g. backends) are implemented as PHP classes:
51
+
- This allows the developer to write a subclass that easily implements a custom data structure.
51
52
- For example, the `git_odb_backend` structure is a class called `GitODBBackend`.
52
53
- A developer could subclass `GitODBBackend` to provide an alternate storage mechanism for a repository's object database (such as a MySQL or SQLite database)
53
54
- Most other data structures are implemented using arrays
@@ -71,7 +72,7 @@ The extension will keep the `git_repository` object alive behind the scenes sinc
71
72
72
73
### Programming methodology
73
74
74
-
Most of the extension is designed as inline code in header files. We use C++ metaprogramming constructs to generate extension functions. This approach is great for streamlining redundant tasks, separating the prototype for a binding from its implementation and keeping track of API changes. However, it comes with the small drawback of decreased flexibility when implementing unusual or more custom bindings.
75
+
Most of the extension is designed as inline code in header files. (A header file is provided for each major section of the `libgit2` API, such as `git_repository`.) We use C++ metaprogramming constructs to generate extension functions. This approach is great for streamlining redundant tasks, separating the prototype for a binding from its implementation and keeping track of API changes. However, it comes with the small drawback of decreased flexibility when implementing unusual or more custom bindings.
75
76
76
77
If a binding doesn't "fit the mold" and cannot be implemented using one of the generic binding template function generators, then we recommend the binding be written directly in the header file using the conventional `PHP_FUNCTION` macro.
77
78
@@ -142,6 +143,7 @@ This project does not officially support Windows at this time. With this said, t
142
143
| -- | -- |
143
144
| Improve unit testing | Complete (October 2022) |
144
145
| Update to `libgit2` version 1 | Complete (January 2023) |
145
-
| Add support for PHP 8 |In progress|
146
+
| Add support for PHP 8 |Complete (September 2023)|
146
147
| Add support for custom `libgit2` memory allocator utilizing PHP's memory allocation functionality | Pending |
147
148
| Create phpdoc files to generate documentation site | Pending |
0 commit comments