Fork me on GitHub

BlackFox

PHP framework for web-sites and applications

Model

/Docs/classes/Feedback.php
namespace Docs;
class  extends \BlackFox\SCRUD {

	public $fields = [
		'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($element) {
		$element['MOMENT'] = time();
		return parent::Create($element);
	}
}

Controller

/Docs/units/UnitFeedback/UnitFeedback.php
namespace Docs;
class UnitFeedback extends \BlackFox\Unit {

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

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

}



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

View

/Docs/units/UnitFeedback/view/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">
			<?
			\BlackFox\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
\BlackFox\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