Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Проєкт на CakePHP
- Необхідно мати
- встановлений PHP https://www.php.net
- MySQL https://www.mysql.com
- ## Встановити Composer
- ## Composer https://getcomposer.org
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- ## Створення проекту https://cakephp.org
- php ./composer.phar create-project --prefer-dist cakephp/app:4.* mydemo
- ./bin/cake server
- # Налаштуванни БД https://book.cakephp.org/4/en/development/configuration.html
- # config/app_local.php
- # Наповнення БД
- # https://book.cakephp.org/4/en/tutorials-and-examples/cms/database.html
- CREATE TABLE users (
- id INT AUTO_INCREMENT PRIMARY KEY,
- email VARCHAR(255) NOT NULL,
- password VARCHAR(255) NOT NULL,
- created DATETIME,
- modified DATETIME
- );
- CREATE TABLE articles (
- id INT AUTO_INCREMENT PRIMARY KEY,
- user_id INT NOT NULL,
- title VARCHAR(255) NOT NULL,
- slug VARCHAR(191) NOT NULL,
- body TEXT,
- published BOOLEAN DEFAULT FALSE,
- created DATETIME,
- modified DATETIME,
- UNIQUE KEY (slug),
- FOREIGN KEY user_key (user_id) REFERENCES users(id)
- ) CHARSET=utf8mb4;
- CREATE TABLE tags (
- id INT AUTO_INCREMENT PRIMARY KEY,
- title VARCHAR(191),
- created DATETIME,
- modified DATETIME,
- UNIQUE KEY (title)
- ) CHARSET=utf8mb4;
- CREATE TABLE articles_tags (
- article_id INT NOT NULL,
- tag_id INT NOT NULL,
- PRIMARY KEY (article_id, tag_id),
- FOREIGN KEY tag_key(tag_id) REFERENCES tags(id),
- FOREIGN KEY article_key(article_id) REFERENCES articles(id)
- );
- INSERT INTO users (email, password, created, modified)
- VALUES
- ('cakephp@example.com', 'secret', NOW(), NOW());
- INSERT INTO articles (user_id, title, slug, body, published, created, modified)
- VALUES
- (1, 'First Post', 'first-post', 'This is the first post.', 1, NOW(), NOW());
- ## Bake
- bin/cake bake model all
- bin/cake bake controller articles
- bin/cake bake template Articles
- # https://milligram.io/
- ## Додавання плагінів
- // composer.json
- ,
- "repositories": [
- {
- "type": "vcs",
- "url": "https://github.com/yarkm13/cakephp-adminlte-theme"
- }
- ]
- # Тема адмінки https://github.com/maiconpinto/cakephp-adminlte-theme
- # https://maiconpinto.github.io/cakephp-adminlte-theme/start
- php ../composer.phar require maiconpinto/cakephp-adminlte-theme dev-master
- bin/cake plugin load AdminLTE
- // , ['bootstrap' => true, 'routes' => true]
- // src/Controller/AppController.php
- use Cake\Event\EventInterface;
- public function beforeRender(EventInterface $event)
- {
- if ($this->request->getParam('prefix') == 'Admin') $this->viewBuilder()->setTheme('AdminLTE');
- if ($this->request->getParam('controller') == 'Pages') $this->viewBuilder()->setTheme('AdminLTE');
- }
- // AppView.php
- $this->loadHelper('Form', ['className' => 'AdminLTE.Form']);
- // https://book.cakephp.org/4/en/development/routing.html#prefix-routing
- $builder->prefix('Admin', function (RouteBuilder $routes) {
- $routes->fallbacks(DashedRoute::class);
- });
- bin/cake bake controller articles --theme AdminLTE --prefix admin
- bin/cake bake template articles --theme AdminLTE --prefix admin
- bin/cake bake controller tags --theme AdminLTE --prefix admin
- bin/cake bake template tags --theme AdminLTE --prefix admin
- // src/Controller/Admin/ArticlesController.php:56
- // $article = $this->Articles->newEntity([]);
- ALTER TABLE `articles` DROP FOREIGN KEY `user_key`;
- DROP TABLE `users`;
- ALTER TABLE `articles` CHANGE `user_id` `user_id` CHAR(36) NOT NULL DEFAULT '';
- # Вхід/Реєстрація/Управління користувачами https://github.com/CakeDC/users
- php ../composer.phar require cakedc/users
- bin/cake plugin load CakeDC/Users
- // , ['bootstrap' => true, 'routes' => true]
- bin/cake migrations migrate -p CakeDC/Users
- bin/cake users addSuperuser
- # http://localhost:8765/users/index
- # http://localhost:8765/users/profile
- # https://getbootstrap.com
- # bootstrap-ui — вбудована підтримка Bootstrap https://github.com/FriendsOfCake/bootstrap-ui/tree/cake-4-bs-4
- php ../composer.phar require friendsofcake/bootstrap-ui dev-cake-4-bs-4
- bin/cake plugin load BootstrapUI
- #bin/cake bootstrap install
- php ../composer.phar require twbs/bootstrap:4.x
- php ../composer.phar require components/jquery
- mkdir -p webroot/bootstrap_u_i/css webroot/bootstrap_u_i/js
- cp vendor/twbs/bootstrap/dist/css/* webroot/bootstrap_u_i/css/.
- cp vendor/twbs/bootstrap/dist/js/* webroot/bootstrap_u_i/js/.
- cp vendor/components/jquery/jquery.js webroot/bootstrap_u_i/js/.
- bin/cake bootstrap modify_view
- bin/cake bootstrap copy_layouts
- bin/cake bake template Articles -t BootstrapUI
- https://pastebin.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement