PHP code example of cortezvini97 / orion

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

    

cortezvini97 / orion example snippets


use Orion\Orion;

// Configuração básica
$orion = new Orion([
    'viewsPath' => 'caminho/para/templates',
    'functionsPath' => 'caminho/para/cache',
    // outras configurações
]);

// Renderizar um template com dados
$orion->render('home', [
    'title' => 'Página Inicial',
    'user' => $user,
    'items' => $items
]);

<!-- home.orion.php -->
<html>
<head>
    <title>{{$title}}></title>
</head>
<body>
    <h1>Bem-vindo,  {{$user->name }}!</h1>
    
    <ul>
    @foreach($items as $item)
        <li>{{$item->getName()}}</li>
    @endforeach
    </ul>
</body>
</html>

@@

<!-- child.orion.php -->
@extends('layouts.master')

@section('title', 'Página de Exemplo')

@section('content')
    <p>Este é o conteúdo da página</p>
@endsection

<!-- layouts/master.orion.php -->
<!DOCTYPE html>
<html>
<head>
    <title>@yield('title')</title>
</head>
<body>
    <header>
        @r>
</body>
</html>

use Orion\Orion;

// Registrar uma diretiva personalizada
Orion::directive('uppercase', function ($expression) {
    return " echo strtoupper($expression); 

<p>@uppercase($name)</p>
<p>Data: @datetime(time())</p>

$orion = new Orion([
    'debug' => true
]);


// index.php

// Configurar diretivas personalizadas
Orion::directive('markdown', function ($expression) {
    return " echo parseMarkdown($expression);