Poniżej kod:
* index.php
<?php require 'vendor/autoload.php'; use View\Template\First\Template; use Shop\User; use Shop\SessionsAndCookies; $template = new Template; $template -> siteStart(); $user = new User; $sac = new SessionsAndCookies; $product = new Product; $category = new Categories; $category -> set('name', 'Main', 1); $template -> siteEnd();
* composer.json
{ "autoload": { "psr-4": { "Shop\\": "class", "View\\": "view" } } }
* View/Template/First/template.php
<?php namespace View\Template\First; class Template { private $title; private $footer; public function __construct($TypeOfView = null) { $this -> title = 'Shop'; $this -> footer = ''; $this -> logotype = ''; $this -> view = $TypeOfView; } public function menu() { $db = new Database; $db -> query('SELECT * FROM categories WHERE visibility = 1 ORDER BY name ASC'); $result = $db -> fetchAll(); return $result; } public function siteStart() { echo' <!DOCTYPE html> <html> <html lang="pl-PL"> <head> <meta charset="utf-8"> <meta name="description" content="..."> <meta name="keywords" content="..."> <link rel="stylesheet" href="View/Template/First/css/style.css"> <title>'.$this -> title.'</title> <!-- [if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"> <