2017 © Pedro Peláez
 

library admin

image

follower/admin

  • Friday, December 11, 2015
  • by follower
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Cms build on follower/core framework

Installation

Download

git clone https://github.com/follower90/framework-admin.git cms
cd cms

Setup config.php

Write your database connect options, (*1)

Install composer requirements

composer install

Create schema from objects

./builder schema:update 'admin'
./builder schema:update 'app'

Apply migrate SQL scripts

./builder schema:migrate 'admin'
./builder schema:migrate 'app'

Run with built-in PHP server

Setup host as usual website on your local Apache/Nginx Or just run this command in cms folder using built-in PHP web server., (*2)

php -S localhost:4000

Run with Docker

docker-compose up

Run with nginx

./start_nginx 4000
./stop_nginx 4000

Try http://localhost:4000/ to access web-site Try http://localhost:4000/admin to login admin part, (*3)

Default login/password: admin/1234, (*4)

Features

Routing

Default routing for pages will work as:, (*5)

yoursite.com/controller/action?params=params

Default routing for Api calls will work as:, (*6)

yoursite.com/api.php?method=Controller.action?params=params

You will also get POST variables in your action arguments, (*7)

Also possible to write aliasses for controller name or action name:, (*8)

Router::alias('buildings', 'Catalog');
Router::actionAlias('all', 'index');

Then /buildings/all url will equal to /catalog/index, (*9)

ORM/Mapper/AR

All information you can find here: https://github.com/follower90/framework-core, (*10)

Shortly about ORM:, (*11)

$obj = Orm::findOne('User', ['name'], ['test'], $params);
$obj->setValue('name', 'test');
Orm::save($obj);

Shortly about Mapper:, (*12)

$mapper = OrmMapper::create('User');
$mapper->setFields(['test', 'name', 'amount']);
  ->setFilter(['test', 'name', 'amount'], [1,2,3]);
  ->load();
$users  = $mapper->getCollection();

Shortly about Active Record:, (*13)

$users = User::all()->addFilter('type', $id)->load()->getCollection();
$user = User::find($id);
$user->name = 'Peter';
$user->save();

Shortly about QueryBuilder:, (*14)

$query = new QueryBuilder('User');
$query->setBaseAlias('pc')
  ->select('id', 'title', 'name')
  ->join('left', 'User_Catalog', 'pc', ['catalog', 'another.id'])
  ->where('somevalue', [124, 125])
  ->orderBy('id', 'asc')
  ->limit(20);

echo $query->composeSelectQuery();

Shortly about SQL helper:, (*15)

MySQL::insert($table, $params);
MySQL::update($table, $params, $conditions);
MySQL::delete($table, $conditions);

Admin UI

All components and libs for Admin UI you can take here: https://startbootstrap.com/template-overviews/sb-admin-2/, (*16)

builder

Builder supports * git composer for admin and core repositories * recreate db schema * create new object from class * run sql-migrations * launch unit tests, (*17)

To run builder and see help just type in root:, (*18)

./builder

Api and Controllers

You will create new API endpoints and Contollers in these namespaces: * \App\Api * \App\Controller * \Admin\Api * \Admin\Controller, (*19)

with method method. It automatically will work at these routes:, (*20)

yoursite.com/api.php?method=ControllerName.ActionName
yoursite.com/admin/api.php?method=ControllerName.ActionName

yoursite.com/admin/controllerName/actionName
yoursite.com/controllerName/ActionName

It automatically retrieve to method arguments: * GET parameters * POST parameters * URI-parameters, splitted by slash, (*21)

For example, yoursite.com/admin/page/edit/2 will have key 'edit' with value 2 in \Admin\Controller\Page.methodEdit, (*22)

Snippets

You can use snippets (reusable html-components) in your admin templates., (*23)

Implement method that will return rendered HTML and just call it in *.phtml file:, (*24)

_snippet('snippetName', [$arg1, $arg2, ...]);

Localization

In the templates you should pass all text labels to __ method., (*25)

It will find and output translated value for current user language: 'site_language' in your Config, (*26)

If translation is not existed in your database, it will output entered value and automatically added to translation without value., (*27)

Then you can go to /admin/translation and edit new value., (*28)

<? __('catalog.Name'); ?>

The Versions

11/12 2015

dev-master

9999999-dev

  Sources   Download

The Requires

  • php >=5.3.0

 

by Avatar follower