PHP code example of imissher / first-sprint

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

    

imissher / first-sprint example snippets


Route::get('url', 'path/to/file', [NameController::class, 'func_name']);

// последний массив с передачей класса и названия функции необязателен


Route::post('url', NameController::class, 'func_name');

Route::middleware([
    'url' => 'rule'
]);

use App\Services\Views\View; 

class NameController
{
    public function func_name()
    {
        //some code
        View::render('path/to/view', ['variable name' => $value]);
        //массив значений не обязательный параметр
    }
}

use App\Services\Session\Session;

$s = new Session();

$s->create_session('name', $value); // создание
$s->get_session('name'); // получение
$s->unset_session('name'); // удаление

use App\Services\Session\Session;

$s = new Session();
$s->get_session('varible_name');

    private string $DB_HOST = 'localhost';
    private string $DB_PORT = '3306';
    private string $DB_NAME = "db_name";
    private string $DB_USERNAME = "db_username";
    private string $DB_PASSWORD = "db_password";

use App\Services\Database\DBW;

$db = new DBW();

$db->select(['login', 'password'], 'db_name')->get();

use App\Services\Database\DBW;

$db = new DBW();

$db->select(['*'], 'db_name')->where('id', $id)->get();

$db->select('...')->where('id', $id)->where('email', $email)->get();

$db->select(['*'], 'db_name')->where('id', $arr_id, separator: 'IN')->get();

$db->insert(['name' => 'John', 'key' => 'value'], 'db_name');

$db->delete(['key' => 'value'] ,'db_name');

$db->update(['key' => 'value'], ['id', $id], 'db_name');

$db->select(['*'], 't1')->join(['t1.id' => 't2.t1_id'], 't2')->get();

$db->select(['*'], 't1')->orderBy('field', 'ASC')->get();

$db->select(['*'], 't1')->groupBy('field')->get();

$db->select(['*'], 't1')->like('field', '%text%')->get();

$db->select(['*'], 'db_name')->where('id', $id)->getQuery();
//вернет строку