PHP.GT

Latest releases

ServiceContainer: Chained loaders and generic return types

Published on by Greg Bowler

It’s now possible to chain the loader functions in ServiceContainer classes. This means that the loader functions can in turn have their own typed parameters automatically injected, just like the go functions in webengine.

An improvement has been made the the use of docblocks - now your IDE will understand that the returned type from Container::get is the type that is requested in the parameter. One day PHP will support generics and we’ll not need to depend on doc blocks.

What’s Changed

Full Changelog: https://github.com/PhpGt/ServiceContainer/compare/v1.1.3...v1.2.0

Ulid: Stable release

Published on by Greg Bowler

This stable release is being made because the library has been in use within a number of projects without needing any tweaks.

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>

FileCache: Initial feature complete

Published on by Greg Bowler

The first functionality is implemented and tested within the repository and will progress while it’s being integrated in certain Bright Flair projects.

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).

ServiceContainer: Lazier LazyLoad

Published on by Greg Bowler

The new feature in this release is the “lazier” LazyLoad attribute. Before, the LazyLoad attribute was required to state the type of object it loaded, but now if there’s a return type on the class itself, the type annotation in the attribute is not mandatory.

Along with this feature, the development dependencies have been set to a hard version constraint to help with predictable builds.

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.

Ulid: Initial pre-release

Published on by Greg Bowler

Functionally complete, but until this repository has been used in real world applications, it will remain <v1 until features have been expanded upon.

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.