PHP code example of byjg / xmlnuke

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

    

byjg / xmlnuke example snippets


namespace MyProject\Modules;

use Xmlnuke\Core\Classes\XmlnukeDocument;
use Xmlnuke\Core\Module\BaseModule;

class Home extends BaseModule 
{
    public function __construct()
    {}

    public function CreatePage() 
    {
        $this->defaultXmlnukeDocument = new XmlnukeDocument("Title", "Abstract");
        ...
        return $this->defaultXmlnukeDocument;
    }
}

namespace MyProject\Modules;

use Xmlnuke\Core\Module\BaseModule;

class Home extends BaseModule 
{
    /**
     * etAccessLevel()
    {
        return \Xmlnuke\Core\Enum\AccessLevel::OnlyRole;
    }
    
    public function getRole()
    {
        return new array("DIRECTOR", "MANAGER");
    }
        
    
    /**
     * useCache determines if the XMLNuke will store your page in a cache or not.
     * By default XMLNuke can store in the:
     *   - \Xmlnuke\Core\Cache\ArrayCacheEngine (Static Array), 
     *   - \Xmlnuke\Core\Cache\FileSystemCacheEngine (File System), 
     *   - \Xmlnuke\Core\Cache\MemcachedEngine (MemCached),
     *   - \Xmlnuke\Core\Cache\NoCacheEngine (Ignore Cache)
     * 
     * You can configure your own cache strategy by implementing the interface 
     * \Xmlnuke\Core\Cache\ICacheEngine.
     */ 
    public function useCache()
    {
        if ($this->_action != "")
        {
              return false;
        }
        else
        {
              return true;
        }
    }

    /** 
     * Determines if your page 

namespace MyProject\Classes;

class MyClass
{
    protected $_name;
    public function getName() ...;
    public function setName($value) ...;
        
    protected $_age;
    public function getAge() ...;
    public function setAge($value) ...;
}

namespace MyProject\Modules;

use MyProject\Classes;
use Xmlnuke\Core\Classes\XmlnukeDocument;
use Xmlnuke\Core\Module\BaseModule;

class Home extends BaseModule 
{
    public function CreatePage() 
    {
        $this->defaultXmlnukeDocument = new XmlnukeDocument("Title", "Abstract");
        ...
        
        $myClass = new MyClass();
        $myClass->setName('Joao');
        $myClass->setAge(39);
        ...
        $this->defaultXmlnukeDocument->addXmlnukeObject($myClass);
            
        return $this->defaultXmlnukeDocument;
    }
}
url
http://youserver/xmlnuke.php?module=byjg.home&raw=xml&spath=//MyProject_Classes_MyClass
url
http://yourserver/xmlnuke.php?module=byjg.home&raw=json&xpath=//MyProject_Classes_MyClass;