Fork me on GitHub

BlackFox

PHP framework for web-sites and applications

Model

/site/modules/Docs/classes/Feedback.php
namespace Docs;
class  extends \System\SCRUD {

	public $name = 'Feedback';

	public $structure = [
		'ID'      => self::ID,
		'MOMENT'  => [
			'TYPE'     => 'DATETIME',
			'NAME'     => 'Moment',
			'NOT_NULL' => true,
		],
		'AUTHOR'  => [
			'TYPE'     => 'STRING',
			'NAME'     => 'Author',
			'NOT_NULL' => true,
		],
		'MESSAGE' => [
			'TYPE' => 'TEXT',
			'NAME' => 'Message',
		],
	];

	public function Create($fields) {
		$fields['MOMENT'] = time();
		return parent::Create($fields);
	}
}

Controller

/site/modules/Docs/units/UnitFeedback/UnitFeedback.php
namespace Docs;
class UnitFeedback extends \System\Unit {

	public function Default() {
		$RESULT = ::I()->Select([
			'SORT'  => ['ID' => 'DESC'],
			'LIMIT' => 10,
		]);
		return $RESULT;
	}

	public function AddFeedback(array ) {
		if ($feedback['AUTHOR'] === 'Reuniko') {
			throw new \System\ExceptionAccessDenied();
		}
		$ID = ::I()->Create($feedback);
		$this->Redirect("?ID={$ID}", 'Your feedback has been added');
	}

}



/site/root/feedback.php
\Docs\UnitFeedback::Run([]);

View

/site/modules/Docs/units/UnitFeedback/templates/default/default.php
<div class="row m-5">
	<div class="col">
		<? foreach ($RESULT as $feedback): ?>
			<div>
				<strong title="<?= $feedback['MOMENT'] ?>">
					<?= $feedback['AUTHOR'] ?>
				</strong>:
				<span><?= $feedback['MESSAGE'] ?></span>
			</div>
		<? endforeach; ?>
	</div>
	<div class="col">
		<form method="post">
			<?
			\System\Form::Run([
				'SCRUD'   => \Docs\::I(),
				'FIELDS'  => ['AUTHOR', 'MESSAGE'],
				'DATA'    => $_REQUEST['feedback'] ?: [],
				'ELEMENT' => '',
			]);
			?>
			<button
				class="btn btn-success"
				type="submit"
				name="ACTION"
				value="AddFeedback">Add feedback
			</button>
		</form>
	</div>
</div>

Result

Controller

/site/root/feedback/index.php
\Admin\Adminer::Run(['SCRUD' => Docs\Feedback::I()]);

Result

administrative pages

Paradigms

  • Disclaimer of backward compatibility
    • Nothing limits framework development
    • Allows to be updated through git pull
  • Disclaimer of rules and restrictions
    • Provides only recommendations
    • Be creative in your style
    • Simplifies and speeds up development
  • Disclaimer of 100% testing
    • Tests only in the most necessary places
    • First the code, then the tests
  • Focus on programmer, not on user
    • Logic and structures — in the code, content — in the database
    • For projects that are willing to afford a full-time programmer
  • Focus on external PHP libraries
    • Contains the absolute minimum of necessary
    • You can learn it very fast
  • Balance between simplicity and complexity
    • Simple and affordable interfaces
    • Difficult but steady logic inside

Features

  • Independent VCS between framework and your code
  • Simple traditional routing
  • Ability to override framework files and classes
  • Automatic synchronization of table structures
  • Extremely simple array format for filtering
  • One-many, many-one, many-many links
  • Administrative page for each database table
  • Custom data types
  • Multi-language support
  • View inheritance