NetLife Guru

Standalone Mode with Routing System

The PHP Template Engine offers the flexibility to be used in a standalone mode, ideal for creating simple web pages without relying on an external framework. This mode is especially useful for projects where a full-scale framework might be unnecessary or overly complex.

Implementing the Routing System

In standalone mode, instead of setting up input files using `$templateEngine->setFiles([...]);`, the template engine utilizes a basic routing system configured via `$templateEngine->setRoutes([...]);`. This approach allows for defining different templates for different routes or paths within your application.

Configuration:

    <?php
    $templateEngine = new Nlg\Aurora\Loader([
        'views' => '/views',
        'cache' => '/cache',
    ]);

    $templateEngine->setRoutes([
        '*' => [
            '/layout.html',
            '/components/header.html',
            '/components/footer.html',
            '/components/forms.html',
        ],
        '' => [
            '/pages/index.html',
        ],
        'docs' => [
            '/pages/docs.html',
        ],
        'contact' => [
            '/pages/contact.html',
            '/components/form.html',
        ],
    ]);

    $templateEngine->setLanguageConstants([
        'hello world' => 'Hello World',
    ]);

    $templateEngine->setVariables([
        'lang' => 'en',
        'title' => '...',
        'description' => '...',
        'articles' => [...]
    ]);

    $templateEngine->createCache(true);

    print $templateEngine->render("layout");

Key Points:

Using this setup, you can build a complete web page with multiple routes, solely using the NLG template engine, offering a lightweight yet powerful alternative to more complex frameworks.

Ideal for Web Coders and Collaboration with Developers

The template creation method employed by this PHP Template Engine is particularly well-suited for web coders, emphasizing ease of use and accessibility. This approach facilitates an efficient workflow, especially when collaborating with developers in a team environment.

Key Advantages for Web Coders:

  1. Simplified Template Creation: The template engine allows web coders to focus on designing and structuring web pages without needing deep programming knowledge. This makes it easier to create complex layouts and components.
  2. Seamless Handoff to Developers: Once the templates are crafted, they can be effortlessly passed on to developers. The structured format of the templates ensures that developers can easily integrate them into the broader application context.
  3. Enhanced Collaboration: This approach bridges the gap between design and development. Web coders can work on the visual and structural aspects of the web pages, while developers handle the more technical implementation details.
  4. Maintainability and Scalability: By separating the templates into manageable blocks and components, future updates and enhancements can be executed more efficiently. This separation of concerns not only makes the code more maintainable but also scalable for larger projects.

In summary, the PHP Template Engine is designed to cater to the needs of web coders, providing a user-friendly interface for template creation while ensuring smooth integration with developers' work. This results in a cohesive and efficient team workflow.