PHP.GT

Latest releases

Dom: W3C HTML attribute usage

Published on by Greg Bowler

This minor patch release introduces some changes to the attributes that are exposed on different HTMLElement classes. Each change brings the library closer to the W3C standard.

What’s Changed

Full Changelog: https://github.com/PhpGt/Dom/compare/v4.0.2...v4.0.3

Server: Better debug setup

Published on by Greg Bowler

This is a minor patch release. For users that do not have the xdebug.conf file loaded by default in the php.ini setup for speed reasons, this adds the debug/profile ini flags by default.

Included in this release also is the compatibility with IPv6 addresses.

What’s Changed

Full Changelog: https://github.com/PhpGt/Server/compare/v1.1.3...v1.1.4

Http: Response redirect/reload functions

Published on by Greg Bowler

Two new non-standard functions are added for convenience within WebEngine and other frameworks. Response::redirect and Response::reload.

What’s Changed

New Contributors

Full Changelog: https://github.com/PhpGt/Http/compare/v1.1.4...v1.1.5

DomTemplate: Temporary fix for PHP XML bug 81506

Published on by Greg Bowler

The bug in PHP’s XML implementation deallocates the Text node from memory, even though it might be referenced later. This patch release includes a number of hacky fixes to resolve this downstream, which is a good solution before the PHP bug is fixed.

DomTemplate: Support for Read Only properties

Published on by Greg Bowler

What’s changed:

In this minor release, classes of the application can now take advantage of PHP 8.1’s new readonly keyword. Any properties that are marked as public readonly will be exposed as Bindable values now, removing a lot of boilerplate code on Model classes.

Example:

// Model class:
class PersonModel {
	public function __construct(
		public readonly string $id,
		public readonly string $name,
		public readonly int $age,
	) {}

	#[BindGetter]
	public function getAgeStatus():string {
		return $this->age >= 18
			? "adult"
			: "minor";
	}
}
// Page code:
function go(Input $input, DocumentBinder $binder, PersonRepository $personRepo):void {
	$binder->bindData($personRepo->getById($input->getString("id"));
}
<!-- Page view -->
<div class="user-profile">
	<h1 data-bind:text="name">User name<h1>
	<img src="/asset/img/user-profile/{{id}}.jpg" alt="{{name}}'s user profile" />
	<p>This user is marked as <span data-bind:text="ageStatus">Age Status</span></p>
</div>

TypeSafeGetter: Unit tests

Published on by Greg Bowler

Even though this repository’s responsibility is simply getting a value with a possible type-cast, functionality has now been unit tested in order to ensure how casting works, how nullable fields are checked, and most importantly getting ready for implementing Generic class getting (tracked in issue 4).

Csrf: DOM v4

Published on by Greg Bowler

This release upgrades to phpgt/dom v4, and in the process of working with dependencies introduces hard dependencies (to avoid constant dependabot upgrades).

DomTemplate: Native DOMDocument extension

Published on by Greg Bowler

The major change in this release is the switch to phpgt/dom v4, which now extends the native DOMDocument rather than using a Facade pattern. This greatly improves efficiency.

Changes in functionality also include:

  • cyclic recursion in partials is now handled
  • binding of data only occurs once per bind, unless the data-rebind attribute is present

Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v2.2.4...v3.0.0

Dom: Native DOMDocument extension

Published on by Greg Bowler

In v3, a Facade was implemented to reach 100% compatibility with W3C’s specification.

In this v4 release, we see a drop of the Facade to go back to a native DOMDocument extension. This is because the native libxml bindings are extremely performant, and plain PHP simply can’t compete. We used the existing unit tests to ensure there isn’t any regression in functionality, but there are certain new quirks due to the libxml implementation, clearly documented in the README.

WebEngine: Simplification of default routing

Published on by Greg Bowler

All URLs now force a trailing slash at the end of the URL path - this is beneficial because it allows client side code and server side headers to reference paths relatively (e.g. Location: ./ for a refresh, Location: ../other-dir/ to redirect to a sibling directory.

The default router has had non-page matches removed for simplicity, until the Router package has documented examples of non-page responses.

Build: Limit dependency version

Published on by Greg Bowler

In this minor patch release, the internal Gt/Cli dependency is bumped, and the WebMozart/Glob dependency is set to a lower version to avoid backwards breaking changes.

DomTemplate: Minor bugfixes & PHP 8.1 compatibility

Published on by Greg Bowler

fix: bind multiple attribute placeholders https://github.com/PhpGt/DomTemplate/pull/327

Example: <a href="/path/to/{{project}}/with/{{another}}/attribute/placeholder"> - any attribute can now contain multiple placeholders.

290 default placeholder https://github.com/PhpGt/DomTemplate/pull/328

Example:

Hello, {{name ?? you}}!

fix: resolve deprecation notices https://github.com/PhpGt/DomTemplate/pull/329

PHP 9 will introduce a lot more strict typing, and 8.1 has started emitting deprecation notices. These have all been addressed in this release.

fix: insert template before correct element https://github.com/PhpGt/DomTemplate/pull/330

When template elements have more than one similar siblings, the correct next sibling is remembered, and the template element is inserted in the correct position.

Identify template parents when there are ambiguous XPath selectors https://github.com/PhpGt/DomTemplate/pull/337

Similarly to above, when two or more template elements have similarly-addressed parents, the template element is now always added to the correct one.

Session: Minor type improvement

Published on by Greg Bowler

This minor patch release allows any ArrayAccess object to be used as Config - this is used in WebEngine by passing a ConfigSection object.

Input: PHP 8.1 improvements

Published on by Greg Bowler

New Contributors

Full Changelog: https://github.com/PhpGt/Input/compare/v1.1.2...v1.1.3