PHP code example of atiksoftware / php-framework-amiral

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

    

atiksoftware / php-framework-amiral example snippets


 
 

/** Config  Paths */
define("DIR_ROOT", __DIR__);

define("DIR_CORE", DIR_ROOT . "/core");

define("DIR_SYSTEM", DIR_CORE . "/system");
define("DIR_ENGINE", DIR_CORE . "/engine");
define("DIR_CONTROLLER", DIR_CORE . "/controller");

/** Allow all request from all domains */
define("ALLOW_ORIGIN_ALL", true);

/** Config  Mongodb Database */
define("DB_HOSTNAME", "mongodb://127.0.0.1:27017");
define("DB_USERNAME", "robotorroot");
define("DB_PASSWORD", "rapunzel14A1");
define("DB_DATABASE", "app_firstbooking");


/** Its your composer autoloader file path. Yuou can change to your global folder if you want.
 * But its should contain Amiral framework.
 */

 

    class Posts extends \Atiksoftware\Amiral\Engine
    { 
    }

 
	use \Atiksoftware\Amiral\Tools;
	use \Atiksoftware\Amiral\Router;
	use \Atiksoftware\Cover\Text;
 
	$skip = Tools::GetParam("skip") ?: 0;
	$limit = Tools::GetParam("limit") ?: 100;
	$search = Tools::GetParam("search") ?: "";

	$filter = [];
	if($search && $search != ""){ 
		$search = Text::fixChars(Text::toLower($search));
		$filter = [ '$and' => []];
		$parts = explode(" ",$search);
		foreach($parts as $part){
			$filter['$and'][] = [
				'text' => [
					'$regex' => new \MongoDB\BSON\Regex ( $part)
				]
			]; 
		}
		
	}

	$items = $class->posts->Select(
		$filter,
		["created_time" => -1],
		[],
		$limit,
		$skip
	);

	$return = array_values($items);

core
    controller (this folder containing your model/class files)
        Posts.php
    engine (this folder containing your middle function files)
        posts
          index.php
          list.php
          delete.php
          update.php
        users.php
index.php