PHP code example of panlatent / craft-codepower-pack

1. Go to this page and download the library: Download panlatent/craft-codepower-pack 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/ */

    

panlatent / craft-codepower-pack example snippets



// config/events.php

use craft\services\ProjectConfig;
use craft\web\View;
use panlatent\craft\event\register\Bootstrap;
use panlatent\craft\event\register\RegisterEvent;

return [
    #[Bootstrap]
    function($app) {
        if ($app->request->getIsCpRequest()) {
            // ...
        }
    },

    #[RegisterEvent(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS)]
    function(\craft\events\RegisterTemplateRootsEvent $event) {
        // ...
    },
]


// Query a section 
Section::post->find()



use Panlatent\FormSchema\Forms;

class Volume extends \craft\base\Field
{
    // ...
    
    #[Forms\TextInput]
    public ?string $property1 = null;
    
    #[Forms\KeyValue]
    public array $property2 = [];
    
    // ...
}



use panlatent\craft\attribute\web\AllowAnonymous;
use panlatent\craft\attribute\web\RequiredLogin;
use panlatent\craft\attribute\web\HasAttributes;

class UserController extends \craft\web\Controller
{
    use HasAttributes;
    
    #[AllowAnonymous]
    #[RequiredLogin]
    public function actionIndex()
    {
    
    }
}