PHP code example of friendsofhyperf / once

1. Go to this page and download the library: Download friendsofhyperf/once 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/ */

    

friendsofhyperf / once example snippets


use FriendsOfHyperf\Once\Annotation\Forget;
use FriendsOfHyperf\Once\Annotation\Once;

class Foo
{
    #[Once]
    public function getNumber(): int
    {
        return rand(1, 10000);
    }

    #[Forget]
    public function forgetNumber()
    {
    }
}