PHP code example of astral-php / astral-utilities

1. Go to this page and download the library: Download astral-php/astral-utilities library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

astral-php / astral-utilities example snippets


use Astral\Utilities\Str;
use Astral\Utilities\Date;
use Astral\Utilities\Arr;

Str::slug('Café Astral');           // cafe-astral
Str::truncate($text, 80);
Str::excerpt($text, 30);

Date::format('2026-08-29 14:00');   // 29/08/2026 14:00
Date::diffForHumans($createdAt);    // il y a 3 jours

Arr::only($data, ['id', 'name']);
Arr::except($data, ['password']);
Arr::get($data, 'user.email');
Arr::flatten($nested);

use Astral\Utilities\UtilitiesServiceProvider;

return [
    // …
    UtilitiesServiceProvider::class,
];
bash
composer