PHP code example of label305 / auja

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

    

label305 / auja example snippets


$main = new Main();

$main->setTitle('My Application');
$main->setColor(Main::COLOR_MAIN, '#22bcb9');

/* Add a logout button. */
$logoutButton = new Button();
$logoutButton
  ->setTitle($logoutButton)
  ->setTarget('#logout');
$main->addButton($logoutButton);

/* Add a model. */
$item = new Item();
$item
    ->setTitle('Club')
    ->setIcon('tower')
    ->setTarget('/clubs/menu');
$menu->addMenuItem($item);

/* Add an authentication form. */
$authenticationForm = new Form();
$authenticationForm
    ->setAction('#login')
    ->setMethod('POST');

    /* Add a username text field. */
    $usernameTextFormItem = new TextFormItem();
    $usernameTextFormItem
        ->setName('username')
        ->setLabel('Username');
    $authenticationForm->addFormItem($usernameTextFormItem);
    
    /* Add a password field. */
    $passwordFormItem = new PasswordFormItem();
    $passwordFormItem
        ->setName('password')
        ->setLabel('Password');
    $result->addFormItem($passwordFormItem);
    
    /* Add a submit button. */
    $submitFormItem = new SubmitFormItem();
    $submitFormItem->setText('Login');
    $result->addFormItem($submitFormItem);

$main->setAuthenticationForm($authenticationForm);

return $main;

$menu = new Menu();

/* Add a link item to add a club. */
$addMenuItem = new LinkMenuItem();
$addMenuItem
    ->setName('Add')
    ->setTarget('/clubs/create');
$menu->addMenuItem($addMenuItem);

/* Add a spacer. */
$spacerMenuItem = new SpacerMenuItem();
$spacerMenuItem->setName('Clubs');
$menu->addMenuItem($spacerMenuItem);

/* Add a placeholder for showing a list of clubs. */
$resourceMenuItem = new ResourceMenuItem();
$resourceMenuItem->setTarget('/clubs');
$menu->addMenuItem($resourceMenuItem);

return $menu;

$resource = new Resource();

/* Add Manchester United to the list. */
$item = new LinkMenuItem();
$item
    ->setName('Manchester United')
    ->setTarget('/clubs/1');
$resource->addItem($item);

/* Add FC Bayern Munchen to the list. */
$item = new LinkMenuItem();
$item
    ->setName('FC Bayern München')
    ->setTarget('/clubs/2');
$resource->addItem($item);

/* Provide a url to the next page of clubs. */
$resource->setNextPageUrl('/clubs?page=2');

return $resource;

/* Retrieve the Club instance. */
$club = ...;

$page = new Page();

/* Add a header with a delete button. */
$pageHeader = new PageHeader();
$pageHeader->setText('Edit Club');

$deleteButton = new Button();
$deleteButton
    ->setText('Delete')
    ->setConfirmationMessage('Are you sure?')
    ->setTarget('/clubs/1')
    ->setMethod('DELETE');
$pageHeader->addButton($deleteButton);

$page->addPageComponent($pageHeader);

/* Add the form. */
$form = new Form();
$form
    ->setAction('/clubs/1')
    ->setMethod('PUT');

    /* Add a name text field.  */
    $nameFormItem = new TextFormItem();
    $nameFormItem
        ->setName('name')
        ->setLabel('Name')
        ->setValue($club->getName());
    $form->addFormItem($nameFormItem);
    
    /* Add a submit button. */
    $submitFormItem = new SubmitFormItem();
    $submitFormItem->setText('Submit');
    $form->addFormItem($submitFormItem);
    
$form->addPageComponent($form);
    
return $page;