PHP code example of farme / framework

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

    

farme / framework example snippets


/**
 * @route GET /users/{id}
 * @route POST /users
 */
function user_show($params = []) {
    $user = user_find($params['id']);
    return farme_render('users/show', ['user' => $user]);
}

function user_find($id) {
    return farme_find('users', $id);
}

function user_create($data) {
    return farme_insert('users', $data);
}

<h1><?= farme_escape($user['name']) 

<?= farme_organism('form', [
    'action' => '/login',
    'method' => 'POST',
    'csrf_token' => $csrf_token,
    'submit_text' => 'Sign In',
    'fields' => [
        'email' => [
            'type' => 'email',
            'placeholder' => 'Email Address',
            '

// Simple queries
$users = user_query()
    |> farme_where('status', 1)
    |> farme_order_by('created_at', 'DESC')
    |> farme_get();

// Complex queries with relationships
$posts = post_query()
    |> farme_join('users', 'posts.user_id', 'users.id')
    |> farme_where('users.status', 1)
    |> farme_get();