You are viewing documentation for an outdated version. It is no longer supported!

Release Notes

Support Policy

Athenaeum attempts to follow a release cycle that matches closely to that of Laravelopen in new window. However, due to limited amount of project maintainers, no guarantees can be provided.

VersionPHPLaravelReleaseSecurity Fixes Until
8.x8.2 - ?v11.x~1st Quarter 2024TBD
7.x*8.1 - 8.2v10.xFebruary 16th, 2023February 2024
6.x8.0 - 8.1v9.xApril 5th, 2022February 2023
5.x7.4v8.xOctober 4th, 2020N/A
< 5.x--See CHANGELOG.mdN/A

*: current supported version.

TBD: "To be decided".

v7.x Highlights

These are the highlights of the latest major version of Athenaeum.

PHP v8.1 and Laravel v10.x

PHP version v8.1 is now the minimum required version for Athenaeum. Laravel v10.xopen in new window packages are now used.

Http Conditional Requests

The ETags package has been upgraded to offer support for RFC 9110's conditional requestsopen in new window. The following preconditions are supported by default:

See documentation for details.

DownloadStream Response Helper

As a part of the ETags package, a DownloadStream response helper is now available. It is able to create streamed response for Range requests.

use Illuminate\Support\Facades\Route;
use Aedart\ETags\Preconditions\Responses\DownloadStream;

Route::get('/downloads/{file}', function (DownloadFileRequest $request) {

    return DownloadStream::for($request->resource)
        ->setName($request->route('file'));
});

API Requests

The Http Api package has been upgraded with a few Request abstractions. These can speed up development of API endpoints.

Example Request

use Aedart\Http\Api\Requests\Resources\ShowSingleResourceRequest;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;

class ShowUser extends ShowSingleResourceRequest
{
    public function findRecordOrFail(): Model
    {
        return User::findOrFail($this->route('id'));
    }

    public function mustEvaluatePreconditions(): bool
    {
        return true;
    }
}

Example Action

Route::get('/users/{id}', function (ShowUser $request) {
    return UserResource::make($request->record)
        ->withCache();
})->name('users.show');

Api Resource Http Caching

Additionally, Api Resources now have the ability to set Caching headersopen in new window, ETagopen in new window, and Last-Modified dateopen in new window, via a single method:

Route::get('/addresses/{id}', function ($id) {
    return new AddressResource(Address::findOrFail($id))
        ->withCache();
});

See documentation for details.

Custom Queries for Search and Sorting Filters

The SearchFilter and SearchProcessor now support custom search callbacks.

use Aedart\Filters\Processors\SearchProcessor;
use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder;

$processor = SearchProcessor::make()
        ->columns(function(Builder|EloquentBuilder $query, string $search) {
            return $query
                ->orWhere($column, 'like', "{$search}%");
        });

The same applies for the SortFilter and SortingProcessor.

use Aedart\Filters\Processors\SortingProcessor;

$processor = SortingProcessor::make()
        ->sortable([ 'email', 'name'])
        ->withSortingCallback('email', function($query, $column, $direction) {
            return $query->orderBy("users.{$column}", $direction);
        });

Remove Response Payload Middleware

A new middleware has been added for the Http Api package, which is able to remove a response's body, when a custom query parameter is available. See middleware documentation for details.

Attach File Stream for Http Client

The Http Client now supports uploading a file stream.

use Aedart\Streams\FileStream;

$response = $client  
        ->attachStream('2023_annual.pdf', FileStream::open('/reports/2023_annual.pdf', 'r'))
        ->post('/reports/annual');

Improved Status object

The Status object that is provided for response expectations has been improved. It now contains several helper methods for determining if it matches a desired Http status code.

use Aedart\Contracts\Http\Clients\Responses\Status;
use Teapot\StatusCode\All as StatusCode;

$client
    ->expect(function(Status $status){
        if ($status->isBadGateway()) {
            // ...
        }
            
        if ($status->is(StatusCode::UNPROCESSABLE_ENTITY)) {
            // ...
        }
        
        if ($status->satisfies([ StatusCode::CREATED, StatusCode::NO_CONTENT ])) {
            // ...
        }
        
        // ... etc
    });

Stream hash() accept hashing options

Streams now accept and apply hashing optionsopen in new window in hash() method. This was previously also supported, but required PHP v8.1. PHP version check is no longer performed internally. See documentation for more details.

Stream sync() is now supported

File streams can now have their content synchronised to file, via the sync() method. See example.

to() memory unit method

The Memory utility now offers a to() method, which allows specifying a string unit to convert the memory unit into.

echo Memory::unit(6_270_000_000) // bytes
    ->to('gigabyte', 2); // 6.27

Changelog

Make sure to read the changelogopen in new window for additional information about the latest release, new features, changes and bug fixes.