PHP code example of hummel / php-frame

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

    

hummel / php-frame example snippets




namespace App\Models;

use Hummel\PhpFrame\Models\OrmAbstract;

class Model extends OrmAbstract
{
    protected string $tableName;

    public function __construct()
    {
        $this->tableName = 'your_table_name';
        parent::__construct();
    }
}


    $models = (new Models())->getAll();
    
    $model = (new Models())->getOneBy(['column_name' => "value"]);

    $model = (new Models())->getOneBy(['column_name_1' => "value", 'column_name_2' => 'value']);

	$model = (new Models())->getBy(['column_name_1' => "value", 'column_name_2' => 'value']);

    $model->column_name = 'value';

	$model->save();

	$model->delete();

    $model->withObject(JoinableInterface $model, string $cond_table_primary, string $cond_table_secondary);




namespace App\Controllers;

use Hummel\PhpFrame\Controllers\BaseController;
use App\Models\Model;
use App\Models\Comment;

class DemoController extends BaseController
{
    public function index()
    {
        $id = $this->route->getParams()['id'];
        $users = (new Model())->getAll();

        $comment = new Comment();
        $comment->getOneBy(['email' => "prout"]);

        $this->render('path/to/your/template.php', [
            'usersTemplateVariable' => $users,
        ]);
    }
}

<body class="container pt-5">
    <h1>All users</h1>
        <p>
          if (isset($usersTemplateVariable) && is_array($usersTemplateVariable)): ; 
bash
composer 
$this->route->getParams()['id'];
\
twig
<body class="container pt-5">
    <h1>All users</h1>
        <p>
        {% if (isset($usersTemplateVariable) && is_array($usersTemplateVariable)): %}
            {% foreach ($usersTemplateVariable as $user) { %}
                <p>{{ $user->email }}</p>
            {% } %}

        {% else: %}
            L'email n'est pas défini
        {% endif %}
        </p>
</body>