PHP code example of akqa / silverstripe-tumu

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

    

akqa / silverstripe-tumu example snippets




use Akqa\SilverStripe\Traits\ViteProvider;

class PageController extends ContentController
{
    use ViteProvider;

}



use Akqa\SilverStripe\Traits\ViteProvider;

class PageController extends ContentController
{
    use ViteProvider;

    protected function init()
    {
        parent::init();

        $this->setPackageManager('pnpm');
        $this->setDefaultCssAsset('app/client/src/style.css')
    }

}



use Akqa\SilverStripe\Traits\ViteProvider;

class PageController extends ContentController
{
    use ViteProvider;

    /**
     * @return array<string>
     */
    public function getAdditionalRequirements(): array
    {
        return [
            'app/client/src/print.css' => [
                'media' => 'print'
            ],
            'app/client/src/additional.jsx'
        ];
    }
}

return $this->renderWith('Includes/ViteRequirements', [
    'JSModules' => $jsModules,
    'ModulePreloads' => $this->getViteModulePreloads($manifest, [
        $this->getDefaultJsAsset(),
    ]),
]);

public function getBannerProps(): string
{
    return json_encode([
        'title' => (string) $this->Title,
    ], JSON_THROW_ON_ERROR);
}

use Akqa\SilverStripe\SSR\ReactRenderer;

$html = ReactRenderer::singleton()->render('Banner', [
    'title' => $this->Title,
]);
json
{
    "name": "akqa/project",
    "type": "project",
    "ire-dev": {
        "cambis/silverstan": "^2",
        "phpro/grumphp-shim": "^2",
        "phpunit/phpunit": "^11",
        "squizlabs/php_codesniffer": "^3.13",
        "php-parallel-lint/php-parallel-lint": "^1.4"
    },
    "scripts": {
        "test": "php -d memory_limit=-1 ./vendor/bin/phpunit",
        "phpstan": "phpstan analyse --memory-limit 1024M",
        "lint": "phpcs app/src app/tests",
        "lint:fix": "phpcbf app/src app/tests",
        "coverage": "XDEBUG_MODE=coverage php -d memory_limit=-1 ./vendor/bin/phpunit --coverage-text"
    },
    "config": {
        "platform": {
            "php": "8.4"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}