├── TODO.md ├── app-mvc ├── .gitignore ├── .htaccess ├── 1projeto ├── README.md ├── application │ ├── Controller │ │ ├── CustomersController.php │ │ ├── ErrorController.php │ │ ├── HomeController.php │ │ └── ProductsController.php │ ├── Core │ │ ├── Model.php │ │ └── Router.php │ ├── Libs │ │ └── helper.php │ ├── Model │ │ ├── Customer.php │ │ └── Product.php │ ├── bootstrap.php │ ├── config │ │ └── config.php │ └── view │ │ ├── _templates │ │ ├── footer.php │ │ └── header.php │ │ ├── customers │ │ ├── edit.php │ │ └── index.php │ │ ├── error │ │ └── index.php │ │ ├── home │ │ └── index.php │ │ └── products │ │ ├── edit.php │ │ └── index.php ├── composer.json ├── db-my.sql ├── db-pg.sql └── public │ ├── .htaccess │ ├── css │ └── style.css │ └── index.php ├── app-mvc2 ├── .gitignore ├── .htaccess ├── README.md ├── application │ ├── Controller │ │ ├── CustomersController.php │ │ ├── ErrorController.php │ │ └── HomeController.php │ ├── Core │ │ ├── Model.php │ │ └── Router.php │ ├── Libs │ │ └── helper.php │ ├── Model │ │ └── Customer.php │ ├── bootstrap.php │ ├── config │ │ └── config.php │ └── view │ │ ├── _templates │ │ ├── footer.php │ │ └── header.php │ │ ├── customers │ │ ├── edit.php │ │ └── index.php │ │ ├── error │ │ └── index.php │ │ └── home │ │ └── index.php ├── composer.json ├── db │ ├── migrations │ │ ├── 20190821114033_customers.php │ │ └── 20190821175812_products.php │ └── seeds │ │ ├── Customers.php │ │ └── Products.php ├── phinx.yml └── public │ ├── .htaccess │ ├── css │ └── style.css │ └── index.php ├── app-mvc3 ├── .gitignore ├── .htaccess ├── 1projeto ├── RE ├── application │ ├── Controller │ │ ├── CustomersController.php │ │ ├── ErrorController.php │ │ └── HomeController.php │ ├── Core │ │ ├── Model.php │ │ └── Router.php │ ├── Libs │ │ └── helper.php │ ├── Model │ │ └── Customer.php │ ├── bootstrap.php │ ├── config │ │ └── config.php │ └── view │ │ ├── _templates │ │ ├── footer.php │ │ └── header.php │ │ ├── customers │ │ ├── edit.php │ │ └── index.php │ │ ├── error │ │ └── index.php │ │ └── home │ │ └── index.php ├── composer.json ├── db │ ├── migrations │ │ ├── 20190821114033_customers.php │ │ └── 20190821175812_products.php │ └── seeds │ │ ├── Customers.php │ │ └── Products.php ├── phinx.yml └── public │ ├── .htaccess │ ├── css │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── custom.css │ └── style.css │ └── index.php ├── app-mvc4 ├── .gitignore ├── .htaccess ├── README.md ├── composer.json ├── db-my.sql ├── db-pg.sql ├── packages-add.md ├── public │ ├── .htaccess │ ├── css │ │ └── custom.css │ ├── images │ │ └── mvc.png │ └── index.php └── src │ ├── Controller │ ├── CustomersController.php │ ├── ErrorController.php │ └── HomeController.php │ ├── Core │ ├── Model.php │ └── Router.php │ ├── Libs │ └── Helper.php │ ├── Model │ └── Customer.php │ ├── bootstrap.php │ ├── config │ └── config.php │ └── view │ ├── _templates │ ├── footer.php │ └── header.php │ ├── customers │ ├── edit.php │ └── index.php │ ├── error │ └── index.php │ └── home │ └── index.php ├── app-mvc5 ├── .gitignore ├── .htaccess ├── README.md ├── composer.json ├── db-my.sql ├── db-pg.sql ├── packages-add.md ├── public │ ├── .htaccess │ ├── css │ │ └── custom.css │ ├── images │ │ └── mvc.png │ └── index.php └── src │ ├── Controller │ ├── CustomersController.php │ ├── ErrorController.php │ └── HomeController.php │ ├── Core │ ├── Model.php │ └── Router.php │ ├── Libs │ └── Helper.php │ ├── Model │ └── CustomersModel.php │ ├── View.php │ ├── bootstrap.php │ ├── config │ └── config.php │ └── view │ ├── _templates │ ├── footer.php │ └── header.php │ ├── customers │ ├── add.php │ ├── edit.php │ └── index.php │ ├── error │ └── index.php │ └── home │ └── index.php ├── docs ├── .htaccess ├── 1-introducao.md ├── 2-Porque.md ├── 3-Justificativa.md ├── 4-PadroesProjeto.md ├── 4mvc1.png ├── 4mvc2.png ├── 5-BoasPraticas.md ├── 6-Rotas.md ├── 7-TratamentoErros.md ├── README.md ├── app-mvc4 │ ├── 0Estrutura.md │ ├── 10.1css.md │ ├── 11.1Finalizando.md │ ├── 11.2Migrations.md │ ├── 11.3Faker.md │ ├── 11.4Woops.md │ ├── 12Namespaces.md │ ├── 13BootStrap4.md │ ├── 1composer.json.md │ ├── 2index.php.md │ ├── 3bootstrap.php.md │ ├── 4config.php.md │ ├── 5.1htaccess.md │ ├── 5.2htaccess.md │ ├── 5.3Router.php.md │ ├── 6Helper.php.md │ ├── 7.1Model.php.md │ ├── 7.2Customer.php.md │ ├── 8.1ErrorController.php.md │ ├── 8.2HomeController.php.md │ ├── 8.3CustomersController.php.md │ ├── 9.1error-index.php.md │ ├── 9.2home-index.php.md │ ├── 9.3.1header.php.md │ ├── 9.3.2footer.php.md │ ├── 9.4.1customers-edit.md │ └── 9.4.2customers-index.md └── mini-fw6_tela.png ├── mini-fw5 ├── .gitignore ├── .htaccess ├── README.md ├── composer.json ├── db-my.sql ├── db-pg.sql ├── packages-add.md ├── public │ ├── .htaccess │ ├── css │ │ └── custom.css │ ├── images │ │ └── mvc.png │ └── index.php └── src │ ├── Controller │ ├── CustomersController.php │ ├── ErrorController.php │ └── HomeController.php │ ├── Core │ ├── Model.php │ └── Router.php │ ├── Libs │ └── Helper.php │ ├── Model │ └── CustomersModel.php │ ├── View.php │ ├── bootstrap.php │ ├── config │ └── config.php │ └── view │ ├── _templates │ ├── footer.php │ └── header.php │ ├── customers │ ├── add.php │ ├── edit.php │ └── index.php │ ├── error │ └── index.php │ └── home │ └── index.php ├── mini-fw6 ├── .gitignore ├── .htaccess ├── Changes.md ├── README.md ├── TODO ├── composer.json ├── db-my.sql ├── db-pg.sql ├── packages-add.md ├── public │ ├── .htaccess │ ├── css │ │ └── custom.css │ ├── images │ │ └── mvc.png │ └── index.php └── src │ ├── Controller │ ├── CustomersController.php │ ├── ErrorController.php │ └── ProductsController.php │ ├── Core │ ├── Model.php │ └── Router.php │ ├── Libs │ └── Helper.php │ ├── Model │ ├── CustomersModel.php │ └── ProductsModel.php │ ├── View │ ├── CustomersView.php │ └── ProductsView.php │ ├── bootstrap.php │ ├── config │ └── config.php │ └── template │ ├── _templates │ ├── footer.php │ └── header.php │ ├── customers │ ├── add.php │ ├── edit.php │ └── index.php │ ├── error │ └── index.php │ └── products │ ├── add.php │ ├── edit.php │ └── index.php └── mini-mvc ├── .htaccess ├── README.md ├── app ├── Controller │ ├── ClientesController.php │ ├── ErrorController.php │ ├── FuncionariosController.php │ ├── HomeController.php │ └── ProdutosController.php ├── Core │ ├── Application.php │ └── Model.php ├── Libs │ └── helper.php ├── Model │ ├── Cliente.php │ ├── Funcionario.php │ └── Produto.php ├── config │ └── config.php └── view │ ├── _templates │ ├── footer.php │ └── header.php │ ├── clientes │ ├── edit.php │ └── index.php │ ├── error │ └── index.php │ ├── funcionarios │ ├── edit.php │ └── index.php │ ├── home │ └── index.php │ └── produtos │ ├── edit.php │ └── index.php ├── composer.json ├── db.sql ├── divulgacao ├── public ├── .htaccess ├── css │ └── style.css ├── img │ └── demo-image.png ├── index.php └── js │ └── application.js └── vendor ├── autoload.php └── composer ├── ClassLoader.php ├── LICENSE ├── autoload_classmap.php ├── autoload_namespaces.php ├── autoload_psr4.php ├── autoload_real.php ├── autoload_static.php └── installed.json /TODO.md: -------------------------------------------------------------------------------- 1 | # Lembrando que o aplicativo base não tem qualquer dependência. 2 | 3 | ## Explicar com detalhes o sistema de rotas: 4 | - .htaccess (os dois) 5 | - public/index.php 6 | - application/bootstrap.php 7 | - application/Core/Router.php (aqui inserir paradas e comentar...) 8 | 9 | ## As 3 dependências/pacotes instalados são úteis, mas opcionais, podendo ser removidos. 10 | 11 | - Paginação (Dividir para view, controller e model) 12 | - Busca (Dividir para view, controller e model) 13 | - Usar o mais que puder de metdados dos SGBDs para tornar o aplicativo menos trabalhoso de codificar, puxando as informações diretamente do banco de dados usando os referidos metadados 14 | - Definir rota default no config.php e implementar no Router.php 15 | 16 | ## Criar novas classes para usar: 17 | 18 | ## Front 19 | - form com bons recursos: input, select, radio, check, etc 20 | - table 21 | - links 22 | - images 23 | - modal 24 | - popups com Bootstrap 25 | - tooltip com BS 26 | - datagrid 27 | 28 | ## Arquivos de template: 29 | - header 30 | - footer 31 | 32 | -------------------------------------------------------------------------------- /app-mvc/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | composer.lock 3 | -------------------------------------------------------------------------------- /app-mvc/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine on 2 | RewriteRule ^(.*) public/$1 [L] 3 | -------------------------------------------------------------------------------- /app-mvc/application/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 32 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 33 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 34 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 35 | 36 | // generate a database connection, using the PDO connector 37 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 38 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 39 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /app-mvc/application/Libs/helper.php: -------------------------------------------------------------------------------- 1 | $value) { 25 | 26 | // check if named parameters (':param') or anonymous parameters ('?') are used 27 | if (is_string($key)) { 28 | $keys[] = '/' . $key . '/'; 29 | } else { 30 | $keys[] = '/[?]/'; 31 | } 32 | 33 | // bring parameter into human-readable format 34 | if (is_string($value)) { 35 | $values[$key] = "'" . $value . "'"; 36 | } elseif (is_array($value)) { 37 | $values[$key] = implode(',', $value); 38 | } elseif (is_null($value)) { 39 | $values[$key] = 'NULL'; 40 | } 41 | } 42 | 43 | /* 44 | echo "
[DEBUG] Keys:
";
45 |         print_r($keys);
46 | 
47 |         echo "\n[DEBUG] Values: ";
48 |         print_r($values);
49 |         echo "
"; 50 | */ 51 | 52 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 53 | 54 | return $raw_sql; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app-mvc/application/bootstrap.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | // set a constant that holds the project's folder path, like "/var/www/". 22 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 23 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 24 | 25 | // set a constant that holds the project's "application" folder, like "/var/www/application". 26 | define('APP', ROOT . 'application' . DIRECTORY_SEPARATOR); 27 | 28 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 29 | require_once ROOT . 'vendor/autoload.php'; 30 | 31 | // load application config (error reporting etc.) 32 | require_once APP . 'config/config.php'; 33 | 34 | // load application class 35 | use Mvc\Core\Router; 36 | 37 | // start the application 38 | $app = new Router(); 39 | -------------------------------------------------------------------------------- /app-mvc/application/config/config.php: -------------------------------------------------------------------------------- 1 | 3 | Find MINI3 on GitHub. 4 | If you like the project, support it by using Rackspace as your hoster [affiliate link]. 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app-mvc/application/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | APP-MVC 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

APP-MVC

19 |


20 | 21 | 26 | -------------------------------------------------------------------------------- /app-mvc/application/view/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

You are in the View: application/view/customers/edit.php (everything in this box comes from that file)

3 | 4 |
5 |

Edit a customer

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /app-mvc/application/view/customers/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 |

You are in the View: application/view/customers/index.php (everything in this box comes from that file)

4 | 5 | 6 |
7 |

Add a customer

8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 | 19 |
20 |

Amount of customers:

21 |

List of customers (data from model)

22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
IdNameE-mailBirthdayDELETEEDIT
id)) echo htmlspecialchars($customer->id, ENT_QUOTES, 'UTF-8'); ?>name)) echo htmlspecialchars($customer->name, ENT_QUOTES, 'UTF-8'); ?>email)) echo htmlspecialchars($customer->email, ENT_QUOTES, 'UTF-8'); ?>birthday)) echo htmlspecialchars($customer->birthday, ENT_QUOTES, 'UTF-8'); ?>deleteedit
46 |
47 |
48 | -------------------------------------------------------------------------------- /app-mvc/application/view/error/index.php: -------------------------------------------------------------------------------- 1 |
2 |

This is the Error-page. Will be shown when a page (= controller / method) does not exist.

3 |
4 | -------------------------------------------------------------------------------- /app-mvc/application/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Home

3 |

You are in the View: application/view/home/index.php (everything in the box comes from this file)

4 |

In a real application this could be the homepage.

5 |
6 | -------------------------------------------------------------------------------- /app-mvc/application/view/products/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

You are in the View: application/view/products/edit.php (everything in this box comes from that file)

3 | 4 |
5 |

Edit a product

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /app-mvc/application/view/products/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Products

3 |

You are in the View: application/view/products/index.php (everything in this box comes from that file)

4 | 5 |
6 |

Add a product

7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 |
19 |

Amount of products:

20 |

List of products (data from model)

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
IdDescriptionUnityDateDELETEEDIT
id)) echo htmlspecialchars($product->id, ENT_QUOTES, 'UTF-8'); ?>description)) echo htmlspecialchars($product->description, ENT_QUOTES, 'UTF-8'); ?>unity)) echo htmlspecialchars($product->unity, ENT_QUOTES, 'UTF-8'); ?>date)) echo htmlspecialchars($product->date, ENT_QUOTES, 'UTF-8'); ?>deleteedit
45 |
46 |
47 | -------------------------------------------------------------------------------- /app-mvc/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/app-mvc", 3 | "description": "APP-MVC - an extremely simple naked MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "dev", 21 | "autoload": 22 | { 23 | "psr-4": 24 | { 25 | "Mvc\\" : "application/" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app-mvc/public/.htaccess: -------------------------------------------------------------------------------- 1 | Options -MultiViews 2 | 3 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 4 | RewriteEngine On 5 | 6 | # Prevent people from looking directly into folders 7 | #Options -Indexes 8 | 9 | # If the following conditions are true, then rewrite the URL: 10 | # If the requested filename is not a directory, 11 | RewriteCond %{REQUEST_FILENAME} !-d 12 | # and if the requested filename is not a regular file that exists, 13 | RewriteCond %{REQUEST_FILENAME} !-f 14 | # and if the requested filename is not a symbolic link, 15 | RewriteCond %{REQUEST_FILENAME} !-l 16 | # then rewrite the URL in the following way: 17 | # Take the whole request filename and provide it as the value of a 18 | # "url" query parameter to index.php. Append any query string from 19 | # the original URL as further query parameters (QSA), and stop 20 | # processing this .htaccess file (L). 21 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 22 | -------------------------------------------------------------------------------- /app-mvc/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | font-size: 14px; 4 | color: #454545; 5 | } 6 | .navigation { 7 | margin-left: 33px; 8 | } 9 | .navigation a { 10 | display: inline-block; 11 | padding: 8px 12px; 12 | border-radius: 3px; 13 | text-decoration: none; 14 | font-size: 12px; 15 | text-transform: uppercase; 16 | font-weight: bold; 17 | border: 1px solid #454545; 18 | color: #454545; 19 | background: transparent; 20 | } 21 | .navigation a:hover { 22 | background: #454545; 23 | color: #fff; 24 | } 25 | .container { 26 | border: 1px solid #454545; 27 | border-radius: 3px; 28 | padding: 20px; 29 | margin: 33px; 30 | } 31 | .container a { 32 | color: #454545; 33 | } 34 | .container table { 35 | font-size: 11px; 36 | margin-top: 20px; 37 | } 38 | .container table thead td { 39 | background-color: #f5f5f5; 40 | padding: 4px 10px; 41 | } 42 | .container table tbody td { 43 | padding: 4px 10px; 44 | } 45 | .container .box { 46 | border-top: 1px solid #ddd; 47 | padding-top: 10px; 48 | margin-top: 30px; 49 | } 50 | .container input { 51 | background-color: #f5f5f5; 52 | border: 0; 53 | padding: 5px 10px; 54 | } 55 | .container input[type="submit"] { 56 | background-color: #ccc; 57 | cursor: pointer; 58 | } 59 | .container input[type="submit"]:hover { 60 | background-color: #222; 61 | color: #fff; 62 | } 63 | .container button { 64 | background-color: #ccc; 65 | border: 0; 66 | padding: 5px 10px; 67 | cursor: pointer; 68 | } 69 | .container button:hover { 70 | background-color: #222; 71 | color: #fff; 72 | } 73 | .footer { 74 | border-radius: 3px; 75 | padding: 20px; 76 | margin: 33px; 77 | text-align: right; 78 | font-size: 11px; 79 | } 80 | .footer a { 81 | color: #454545; 82 | } 83 | -------------------------------------------------------------------------------- /app-mvc/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | 22 | declare(strict_types = 1); 23 | 24 | require __DIR__ . '/../application/bootstrap.php'; 25 | 26 | -------------------------------------------------------------------------------- /app-mvc2/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .vscode 3 | composer.lock 4 | 5 | -------------------------------------------------------------------------------- /app-mvc2/.htaccess: -------------------------------------------------------------------------------- 1 | # This file is - if you set up MINI correctly - not needed. 2 | # But, for fallback reasons (if you don't route your vhost to /public), it will stay here. 3 | RewriteEngine on 4 | RewriteRule ^(.*) public/$1 [L] 5 | -------------------------------------------------------------------------------- /app-mvc2/README.md: -------------------------------------------------------------------------------- 1 | # app-mvc2 2 | 3 | ## Esta versão tem como diferença da original a instalação de duas dependências: 4 | 5 | - robmorgan/phinx - migrations 6 | - fzaninotto/faker - geração de dados falsos 7 | 8 | ## Estas dependências são opcionais, inteiramente desacopladas, usadas somente para geração de migrations/seeds 9 | 10 | Caso deseje pode removê-las 11 | 12 | ## Instalação do app-mvc2 13 | 14 | Acesse a pasta e execute 15 | ```bash 16 | composer update 17 | ``` 18 | 19 | ## Instalar migrations 20 | 21 | Atualize os dados do banco no arquivo do raiz 22 | 23 | phinx.yml 24 | 25 | Execute: 26 | ```bash 27 | php vendor/robmorgan/phinx/bin/phinx migrate -e production 28 | php vendor/bin/phinx seed:run -e production 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /app-mvc2/application/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 32 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 33 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 34 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 35 | 36 | // generate a database connection, using the PDO connector 37 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 38 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 39 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /app-mvc2/application/Libs/helper.php: -------------------------------------------------------------------------------- 1 | $value) { 24 | 25 | // check if named parameters (':param') or anonymous parameters ('?') are used 26 | if (is_string($key)) { 27 | $keys[] = '/' . $key . '/'; 28 | } else { 29 | $keys[] = '/[?]/'; 30 | } 31 | 32 | // bring parameter into human-readable format 33 | if (is_string($value)) { 34 | $values[$key] = "'" . $value . "'"; 35 | } elseif (is_array($value)) { 36 | $values[$key] = implode(',', $value); 37 | } elseif (is_null($value)) { 38 | $values[$key] = 'NULL'; 39 | } 40 | } 41 | 42 | /* 43 | echo "
[DEBUG] Keys:
";
44 |         print_r($keys);
45 | 
46 |         echo "\n[DEBUG] Values: ";
47 |         print_r($values);
48 |         echo "
"; 49 | */ 50 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 51 | return $raw_sql; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app-mvc2/application/bootstrap.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | // set a constant that holds the project's folder path, like "/var/www/". 22 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 23 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 24 | 25 | // set a constant that holds the project's "application" folder, like "/var/www/application". 26 | define('APP', ROOT . 'application' . DIRECTORY_SEPARATOR); 27 | 28 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 29 | require_once ROOT . 'vendor/autoload.php'; 30 | 31 | // load application config (error reporting etc.) 32 | require_once APP . 'config/config.php'; 33 | 34 | // load application class 35 | use Mvc\Core\Router; 36 | 37 | // start the application 38 | $app = new Router(); 39 | -------------------------------------------------------------------------------- /app-mvc2/application/config/config.php: -------------------------------------------------------------------------------- 1 | 3 | Find MINI3 on GitHub. 4 | If you like the project, support it by using Rackspace as your hoster [affiliate link]. 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-mvc2/application/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | APP-MVC 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

APP-MVC

19 |


20 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /app-mvc2/application/view/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

You are in the View: application/view/customers/edit.php (everything in this box comes from that file)

3 | 4 |
5 |

Edit a customer

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /app-mvc2/application/view/customers/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 |

You are in the View: application/view/customers/index.php (everything in this box comes from that file)

4 | 5 | 6 |
7 |

Add a customer

8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 | 19 |
20 |

Amount of customers:

21 |

List of customers (data from model)

22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
IdNameE-mailBirthdayDELETEEDIT
id)) echo htmlspecialchars($customer->id, ENT_QUOTES, 'UTF-8'); ?>name)) echo htmlspecialchars($customer->name, ENT_QUOTES, 'UTF-8'); ?>email)) echo htmlspecialchars($customer->email, ENT_QUOTES, 'UTF-8'); ?>birthday)) echo htmlspecialchars($customer->birthday, ENT_QUOTES, 'UTF-8'); ?>deleteedit
46 |
47 |
48 | -------------------------------------------------------------------------------- /app-mvc2/application/view/error/index.php: -------------------------------------------------------------------------------- 1 |
2 |

This is the Error-page. Will be shown when a page (= controller / method) does not exist.

3 |
4 | 5 | -------------------------------------------------------------------------------- /app-mvc2/application/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Home

3 |

You are in the View: application/view/home/index.php (everything in the box comes from this file)

4 |

In a real application this could be the homepage.

5 |
6 | 7 | -------------------------------------------------------------------------------- /app-mvc2/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/app-mvc", 3 | "description": "APP-MVC - an extremely simple naked MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "dev", 21 | "require": { 22 | "robmorgan/phinx": "dev-master", 23 | "fzaninotto/faker": "^1.9@dev" 24 | }, 25 | "autoload": 26 | { 27 | "psr-4": 28 | { 29 | "Mvc\\" : "application/" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app-mvc2/db/migrations/20190821114033_customers.php: -------------------------------------------------------------------------------- 1 | table('customers') 35 | ->addColumn('name', 'string') 36 | ->addColumn('email', 'string') 37 | ->addColumn('birthday', 'date') 38 | ->addColumn('created', 'datetime',['default'=>'CURRENT_TIMESTAMP']) 39 | ->create(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app-mvc2/db/migrations/20190821175812_products.php: -------------------------------------------------------------------------------- 1 | table('products') 35 | ->addColumn('description', 'string', ['limit' => 50]) 36 | ->addColumn('unity', 'string', ['limit' => 5]) 37 | ->addColumn('date', 'date', ['null' => true]) 38 | ->addColumn('created', 'datetime',['default'=>'CURRENT_TIMESTAMP']) 39 | ->create(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app-mvc2/db/seeds/Customers.php: -------------------------------------------------------------------------------- 1 | $faker->name, 23 | 'email' => $faker->email, 24 | 'birthday' => $faker->date('Y-m-d'), 25 | 'created' => date('Y-m-d H:i:s'), 26 | ]; 27 | } 28 | // $this->insert('products', $data); 29 | $posts = $this->table('customers'); 30 | $posts->insert($data) 31 | ->save(); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app-mvc2/db/seeds/Products.php: -------------------------------------------------------------------------------- 1 | $faker->name, 23 | 'unity' => $faker->regexify('[A-Z]3'), 24 | 'date' => $faker->date('Y-m-d'), 25 | 'created' => date('Y-m-d H:i:s'), 26 | ]; 27 | } 28 | 29 | $this->insert('products', $data); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app-mvc2/phinx.yml: -------------------------------------------------------------------------------- 1 | paths: 2 | migrations: '%%PHINX_CONFIG_DIR%%/db/migrations' 3 | seeds: '%%PHINX_CONFIG_DIR%%/db/seeds' 4 | 5 | environments: 6 | default_migration_table: phinxlog 7 | default_database: development 8 | production: 9 | adapter: mysql 10 | host: localhost 11 | name: app-mvc 12 | user: root 13 | pass: 'root' 14 | port: 3306 15 | charset: utf8 16 | 17 | development: 18 | adapter: mysql 19 | host: localhost 20 | name: development_db 21 | user: root 22 | pass: '' 23 | port: 3306 24 | charset: utf8 25 | 26 | testing: 27 | adapter: mysql 28 | host: localhost 29 | name: testing_db 30 | user: root 31 | pass: '' 32 | port: 3306 33 | charset: utf8 34 | 35 | version_order: creation 36 | -------------------------------------------------------------------------------- /app-mvc2/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /app-mvc2/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | font-size: 14px; 4 | color: #454545; 5 | } 6 | .navigation { 7 | margin-left: 33px; 8 | } 9 | .navigation a { 10 | display: inline-block; 11 | padding: 8px 12px; 12 | border-radius: 3px; 13 | text-decoration: none; 14 | font-size: 12px; 15 | text-transform: uppercase; 16 | font-weight: bold; 17 | border: 1px solid #454545; 18 | color: #454545; 19 | background: transparent; 20 | } 21 | .navigation a:hover { 22 | background: #454545; 23 | color: #fff; 24 | } 25 | .container { 26 | border: 1px solid #454545; 27 | border-radius: 3px; 28 | padding: 20px; 29 | margin: 33px; 30 | } 31 | .container a { 32 | color: #454545; 33 | } 34 | .container table { 35 | font-size: 11px; 36 | margin-top: 20px; 37 | } 38 | .container table thead td { 39 | background-color: #f5f5f5; 40 | padding: 4px 10px; 41 | } 42 | .container table tbody td { 43 | padding: 4px 10px; 44 | } 45 | .container .box { 46 | border-top: 1px solid #ddd; 47 | padding-top: 10px; 48 | margin-top: 30px; 49 | } 50 | .container input { 51 | background-color: #f5f5f5; 52 | border: 0; 53 | padding: 5px 10px; 54 | } 55 | .container input[type="submit"] { 56 | background-color: #ccc; 57 | cursor: pointer; 58 | } 59 | .container input[type="submit"]:hover { 60 | background-color: #222; 61 | color: #fff; 62 | } 63 | .container button { 64 | background-color: #ccc; 65 | border: 0; 66 | padding: 5px 10px; 67 | cursor: pointer; 68 | } 69 | .container button:hover { 70 | background-color: #222; 71 | color: #fff; 72 | } 73 | .footer { 74 | border-radius: 3px; 75 | padding: 20px; 76 | margin: 33px; 77 | text-align: right; 78 | font-size: 11px; 79 | } 80 | .footer a { 81 | color: #454545; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /app-mvc2/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | 22 | declare(strict_types = 1); 23 | 24 | require __DIR__ . '/../application/bootstrap.php'; 25 | 26 | -------------------------------------------------------------------------------- /app-mvc3/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .vscode 3 | composer.lock 4 | 5 | -------------------------------------------------------------------------------- /app-mvc3/.htaccess: -------------------------------------------------------------------------------- 1 | # This file is - if you set up MINI correctly - not needed. 2 | # But, for fallback reasons (if you don't route your vhost to /public), it will stay here. 3 | RewriteEngine on 4 | RewriteRule ^(.*) public/$1 [L] 5 | -------------------------------------------------------------------------------- /app-mvc3/1projeto: -------------------------------------------------------------------------------- 1 | Esta versão trocou o CSS original pelo BootStrap 4 2 | 3 | Caso queira experimentar os dados existentes, então edite o arquivo do raiz 4 | phinx.yml 5 | 6 | E ajuste os dados do banco de dados no ambiente production ou noutro mas lembre de alterar os comandos abaixo: 7 | php vendor/robmorgan/phinx/bin/phinx migrate -e production 8 | php vendor/bin/phinx seed:run -e production 9 | -------------------------------------------------------------------------------- /app-mvc3/RE: -------------------------------------------------------------------------------- 1 | # app-mvc3 2 | 3 | ## Instalação do app-mvc2 4 | 5 | Acesse a pasta e execute 6 | ```bash 7 | composer update 8 | ``` 9 | -------------------------------------------------------------------------------- /app-mvc3/application/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 32 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 33 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 34 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 35 | 36 | // generate a database connection, using the PDO connector 37 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 38 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 39 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /app-mvc3/application/Libs/helper.php: -------------------------------------------------------------------------------- 1 | $value) { 24 | 25 | // check if named parameters (':param') or anonymous parameters ('?') are used 26 | if (is_string($key)) { 27 | $keys[] = '/' . $key . '/'; 28 | } else { 29 | $keys[] = '/[?]/'; 30 | } 31 | 32 | // bring parameter into human-readable format 33 | if (is_string($value)) { 34 | $values[$key] = "'" . $value . "'"; 35 | } elseif (is_array($value)) { 36 | $values[$key] = implode(',', $value); 37 | } elseif (is_null($value)) { 38 | $values[$key] = 'NULL'; 39 | } 40 | } 41 | 42 | /* 43 | echo "
[DEBUG] Keys:
";
44 |         print_r($keys);
45 | 
46 |         echo "\n[DEBUG] Values: ";
47 |         print_r($values);
48 |         echo "
"; 49 | */ 50 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 51 | return $raw_sql; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app-mvc3/application/bootstrap.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | // set a constant that holds the project's folder path, like "/var/www/". 22 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 23 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 24 | 25 | // set a constant that holds the project's "application" folder, like "/var/www/application". 26 | define('APP', ROOT . 'application' . DIRECTORY_SEPARATOR); 27 | 28 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 29 | require_once ROOT . 'vendor/autoload.php'; 30 | 31 | // load application config (error reporting etc.) 32 | require_once APP . 'config/config.php'; 33 | 34 | // load application class 35 | use Mvc\Core\Router; 36 | 37 | // start the application 38 | $app = new Router(); 39 | -------------------------------------------------------------------------------- /app-mvc3/application/config/config.php: -------------------------------------------------------------------------------- 1 | 3 | Find MINI3 on GitHub. 4 | If you like the project, support it by using Rackspace as your hoster [affiliate link]. 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-mvc3/application/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | APP-MVC 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 |

APP-MVC

22 | 23 | 33 | -------------------------------------------------------------------------------- /app-mvc3/application/view/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

You are in the View: application/view/customers/edit.php (everything in this box comes from that file)

3 | 4 |
5 |

Edit a customer

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /app-mvc3/application/view/error/index.php: -------------------------------------------------------------------------------- 1 |
2 |

This is the Error-page. Will be shown when a page (= controller / method) does not exist.

3 |
4 | 5 | -------------------------------------------------------------------------------- /app-mvc3/application/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Home

3 | You are in the View: application/view/home/index.php (everything in the box comes from this file)
4 |

In a real application this could be the homepage.

5 |
6 |




7 | 8 | -------------------------------------------------------------------------------- /app-mvc3/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/app-mvc", 3 | "description": "APP-MVC - an extremely simple naked MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "dev", 21 | "require": { 22 | "robmorgan/phinx": "dev-master", 23 | "fzaninotto/faker": "^1.9@dev" 24 | }, 25 | "autoload": 26 | { 27 | "psr-4": 28 | { 29 | "Mvc\\" : "application/" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app-mvc3/db/migrations/20190821114033_customers.php: -------------------------------------------------------------------------------- 1 | table('customers') 35 | ->addColumn('name', 'string') 36 | ->addColumn('email', 'string') 37 | ->addColumn('birthday', 'date') 38 | ->addColumn('created', 'datetime',['default'=>'CURRENT_TIMESTAMP']) 39 | ->create(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app-mvc3/db/migrations/20190821175812_products.php: -------------------------------------------------------------------------------- 1 | table('products') 35 | ->addColumn('description', 'string', ['limit' => 50]) 36 | ->addColumn('unity', 'string', ['limit' => 5]) 37 | ->addColumn('date', 'date', ['null' => true]) 38 | ->addColumn('created', 'datetime',['default'=>'CURRENT_TIMESTAMP']) 39 | ->create(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app-mvc3/db/seeds/Customers.php: -------------------------------------------------------------------------------- 1 | $faker->name, 23 | 'email' => $faker->email, 24 | 'birthday' => $faker->date('Y-m-d'), 25 | 'created' => date('Y-m-d H:i:s'), 26 | ]; 27 | } 28 | // $this->insert('products', $data); 29 | $posts = $this->table('customers'); 30 | $posts->insert($data) 31 | ->save(); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app-mvc3/db/seeds/Products.php: -------------------------------------------------------------------------------- 1 | $faker->name, 23 | 'unity' => $faker->regexify('[A-Z]3'), 24 | 'date' => $faker->date('Y-m-d'), 25 | 'created' => date('Y-m-d H:i:s'), 26 | ]; 27 | } 28 | 29 | $this->insert('products', $data); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app-mvc3/phinx.yml: -------------------------------------------------------------------------------- 1 | paths: 2 | migrations: '%%PHINX_CONFIG_DIR%%/db/migrations' 3 | seeds: '%%PHINX_CONFIG_DIR%%/db/seeds' 4 | 5 | environments: 6 | default_migration_table: phinxlog 7 | default_database: development 8 | production: 9 | adapter: mysql 10 | host: localhost 11 | name: app-mvc 12 | user: root 13 | pass: 'root' 14 | port: 3306 15 | charset: utf8 16 | 17 | development: 18 | adapter: mysql 19 | host: localhost 20 | name: development_db 21 | user: root 22 | pass: '' 23 | port: 3306 24 | charset: utf8 25 | 26 | testing: 27 | adapter: mysql 28 | host: localhost 29 | name: testing_db 30 | user: root 31 | pass: '' 32 | port: 3306 33 | charset: utf8 34 | 35 | version_order: creation 36 | -------------------------------------------------------------------------------- /app-mvc3/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /app-mvc3/public/css/custom.css: -------------------------------------------------------------------------------- 1 | .navbar-dark .navbar-nav .nav-link { 2 | color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /app-mvc3/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | font-size: 14px; 4 | color: #454545; 5 | } 6 | .navigation { 7 | margin-left: 33px; 8 | } 9 | .navigation a { 10 | display: inline-block; 11 | padding: 8px 12px; 12 | border-radius: 3px; 13 | text-decoration: none; 14 | font-size: 12px; 15 | text-transform: uppercase; 16 | font-weight: bold; 17 | border: 1px solid #454545; 18 | color: #454545; 19 | background: transparent; 20 | } 21 | .navigation a:hover { 22 | background: #454545; 23 | color: #fff; 24 | } 25 | .container { 26 | border: 1px solid #454545; 27 | border-radius: 3px; 28 | padding: 20px; 29 | margin: 33px; 30 | } 31 | .container a { 32 | color: #454545; 33 | } 34 | .container table { 35 | font-size: 11px; 36 | margin-top: 20px; 37 | } 38 | .container table thead td { 39 | background-color: #f5f5f5; 40 | padding: 4px 10px; 41 | } 42 | .container table tbody td { 43 | padding: 4px 10px; 44 | } 45 | .container .box { 46 | border-top: 1px solid #ddd; 47 | padding-top: 10px; 48 | margin-top: 30px; 49 | } 50 | .container input { 51 | background-color: #f5f5f5; 52 | border: 0; 53 | padding: 5px 10px; 54 | } 55 | .container input[type="submit"] { 56 | background-color: #ccc; 57 | cursor: pointer; 58 | } 59 | .container input[type="submit"]:hover { 60 | background-color: #222; 61 | color: #fff; 62 | } 63 | .container button { 64 | background-color: #ccc; 65 | border: 0; 66 | padding: 5px 10px; 67 | cursor: pointer; 68 | } 69 | .container button:hover { 70 | background-color: #222; 71 | color: #fff; 72 | } 73 | .footer { 74 | border-radius: 3px; 75 | padding: 20px; 76 | margin: 33px; 77 | text-align: right; 78 | font-size: 11px; 79 | } 80 | .footer a { 81 | color: #454545; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /app-mvc3/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | 22 | declare(strict_types = 1); 23 | 24 | require __DIR__ . '/../application/bootstrap.php'; 25 | 26 | -------------------------------------------------------------------------------- /app-mvc4/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | composer.lock 3 | 4 | -------------------------------------------------------------------------------- /app-mvc4/.htaccess: -------------------------------------------------------------------------------- 1 | # This file is - if you set up MINI correctly - not needed. 2 | # But, for fallback reasons (if you don't route your vhost to /public), it will stay here. 3 | RewriteEngine on 4 | RewriteRule ^(.*) public/$1 [L] 5 | -------------------------------------------------------------------------------- /app-mvc4/README.md: -------------------------------------------------------------------------------- 1 | # app-mvc4 2 | 3 | ## Esta versão trocou o CSS original pelo BootStrap 4 4 | 5 | - Renomeou a pasta application para src 6 | 7 | - Nesta versão também começamos a adotar a declaração 8 | declare(strict_types = 1); 9 | - No início de cada arquivo para obrigar a declaração de tipos em métodos e retornos. 10 | - Em caso de uso de tipo incompatível dispara: Fatal error: Uncaught TypeError: 11 | - Nesta versão foi testado o suporte ao PostgreSQL E efetuados ajustes para que funcionasse 12 | 13 | ## Instalação 14 | 15 | Acesse a pasta e execute 16 | ```bash 17 | composer update 18 | ``` 19 | ## Instalar migrations 20 | 21 | Atualize os dados do banco no arquivo do raiz 22 | 23 | phinx.yml 24 | 25 | Execute: 26 | ```bash 27 | php vendor/robmorgan/phinx/bin/phinx migrate -e production 28 | php vendor/bin/phinx seed:run -e production 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /app-mvc4/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/app-mvc", 3 | "description": "APP-MVC - an extremely simple naked MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "stable", 21 | "require": { 22 | 23 | }, 24 | "autoload": 25 | { 26 | "psr-4": 27 | { 28 | "Mvc\\" : "src/" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app-mvc4/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /app-mvc4/public/css/custom.css: -------------------------------------------------------------------------------- 1 | .navbar-dark .navbar-nav .nav-link { 2 | color: #a1e1ed; 3 | } 4 | .center-img { 5 | display: block; 6 | margin-left: auto; 7 | margin-right: auto; 8 | width: 20%; 9 | } 10 | -------------------------------------------------------------------------------- /app-mvc4/public/images/mvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/app-mvc4/public/images/mvc.png -------------------------------------------------------------------------------- /app-mvc4/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | 22 | declare(strict_types = 1); 23 | 24 | require __DIR__ . '/../src/bootstrap.php'; 25 | 26 | -------------------------------------------------------------------------------- /app-mvc4/src/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 32 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 33 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 34 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 35 | 36 | // generate a database connection, using the PDO connector 37 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 38 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 39 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /app-mvc4/src/Libs/Helper.php: -------------------------------------------------------------------------------- 1 | $value) { 24 | 25 | // check if named parameters (':param') or anonymous parameters ('?') are used 26 | if (is_string($key)) { 27 | $keys[] = '/' . $key . '/'; 28 | } else { 29 | $keys[] = '/[?]/'; 30 | } 31 | 32 | // bring parameter into human-readable format 33 | if (is_string($value)) { 34 | $values[$key] = "'" . $value . "'"; 35 | } elseif (is_array($value)) { 36 | $values[$key] = implode(',', $value); 37 | } elseif (is_null($value)) { 38 | $values[$key] = 'NULL'; 39 | } 40 | } 41 | 42 | /* 43 | echo "
[DEBUG] Keys:
";
44 |         print_r($keys);
45 | 
46 |         echo "\n[DEBUG] Values: ";
47 |         print_r($values);
48 |         echo "
"; 49 | */ 50 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 51 | return $raw_sql; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app-mvc4/src/bootstrap.php: -------------------------------------------------------------------------------- 1 | 19 | * 20 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 21 | */ 22 | 23 | // set a constant that holds the project's folder path, like "/var/www/". 24 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 25 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 26 | 27 | // set a constant that holds the project's "application" folder, like "/var/www/application". 28 | define('APP', ROOT . 'src' . DIRECTORY_SEPARATOR); 29 | 30 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 31 | require_once ROOT . 'vendor/autoload.php'; 32 | 33 | // load application config (error reporting etc.) 34 | require_once APP . 'config/config.php'; 35 | 36 | // load application class 37 | use Mvc\Core\Router; 38 | 39 | // start the application 40 | $app = new Router(); 41 | -------------------------------------------------------------------------------- /app-mvc4/src/view/_templates/footer.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | Find MINI3 on GitHub. 4 | If you like the mini3 project, support it by using Rackspace as your hoster [affiliate link]. 5 |
6 |
7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-mvc4/src/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <?=APP_TITTLE?> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 |

21 | 22 |
23 | 33 |
34 | -------------------------------------------------------------------------------- /app-mvc4/src/view/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |

7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |


20 | -------------------------------------------------------------------------------- /app-mvc4/src/view/error/index.php: -------------------------------------------------------------------------------- 1 |

2 |
3 |

This page ( controller / method) does not exist.

4 |
5 |



6 | -------------------------------------------------------------------------------- /app-mvc4/src/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

3 |

Home

4 |


5 | 6 |

This is the start homepage.

7 |
8 |




9 | 10 | -------------------------------------------------------------------------------- /app-mvc5/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | composer.lock 3 | 4 | -------------------------------------------------------------------------------- /app-mvc5/.htaccess: -------------------------------------------------------------------------------- 1 | # This file is - if you set up MINI correctly - not needed. 2 | # But, for fallback reasons (if you don't route your vhost to /public), it will stay here. 3 | RewriteEngine on 4 | RewriteRule ^(.*) public/$1 [L] 5 | -------------------------------------------------------------------------------- /app-mvc5/README.md: -------------------------------------------------------------------------------- 1 | # app-mvc5 2 | 3 | ## Esta versão trocou o CSS original pelo BootStrap 4 4 | 5 | E cria a classe View() que substitui os requires nos métodos index() e edit() do controller. 6 | 7 | - Renomeou a pasta application para src 8 | 9 | - Nesta versão também começamos a adotar a declaração declare(strict_types = 1); 10 | - No início de cada arquivo para obrigar a declaração de tipos em métodos e retornos. 11 | - Em caso de uso de tipo incompatível dispara: Fatal error: Uncaught TypeError: 12 | 13 | - Nesta versão foi testado o suporte ao PostgreSQL E efetuados ajustes para que funcionasse 14 | 15 | ## Instalação 16 | 17 | Acesse a pasta e execute 18 | ```bash 19 | composer update 20 | ``` 21 | 22 | ## Instalar migrations 23 | 24 | Atualize os dados do banco no arquivo do raiz 25 | 26 | phinx.yml 27 | 28 | Execute: 29 | ```bash 30 | php vendor/robmorgan/phinx/bin/phinx migrate -e production 31 | php vendor/bin/phinx seed:run -e production 32 | ``` 33 | -------------------------------------------------------------------------------- /app-mvc5/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/app-mvc", 3 | "description": "APP-MVC - an extremely simple naked MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "stable", 21 | "require": { 22 | 23 | }, 24 | "autoload": 25 | { 26 | "psr-4": 27 | { 28 | "Mvc\\" : "src/" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app-mvc5/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /app-mvc5/public/css/custom.css: -------------------------------------------------------------------------------- 1 | .navbar-dark .navbar-nav .nav-link { 2 | color: #a1e1ed; 3 | } 4 | .center-img { 5 | display: block; 6 | margin-left: auto; 7 | margin-right: auto; 8 | width: 20%; 9 | } 10 | -------------------------------------------------------------------------------- /app-mvc5/public/images/mvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/app-mvc5/public/images/mvc.png -------------------------------------------------------------------------------- /app-mvc5/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | require __DIR__ . '/../src/bootstrap.php'; 22 | 23 | -------------------------------------------------------------------------------- /app-mvc5/src/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 34 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 35 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 36 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 37 | 38 | // generate a database connection, using the PDO connector 39 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 40 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 41 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 42 | 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /app-mvc5/src/Libs/Helper.php: -------------------------------------------------------------------------------- 1 | $value) { 27 | 28 | // check if named parameters (':param') or anonymous parameters ('?') are used 29 | if (is_string($key)) { 30 | $keys[] = '/' . $key . '/'; 31 | } else { 32 | $keys[] = '/[?]/'; 33 | } 34 | 35 | // bring parameter into human-readable format 36 | if (is_string($value)) { 37 | $values[$key] = ''' . $value . '''; // Before "'" 38 | } elseif (is_array($value)) { 39 | $values[$key] = implode(',', $value); 40 | } elseif (is_null($value)) { 41 | $values[$key] = 'NULL'; 42 | } 43 | } 44 | 45 | /* 46 | echo '
[DEBUG] Keys:
';
47 |         print_r($keys);
48 | 
49 |         echo '
[DEBUG] Values: '; 50 | print_r($values); 51 | echo '
'; 52 | */ 53 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 54 | return $raw_sql; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app-mvc5/src/View.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | // set a constant that holds the project's folder path, like "/var/www/". 22 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 23 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 24 | 25 | // set a constant that holds the project's 'src' folder, like '/var/www/html/app-mvc/src'. 26 | define('APP', ROOT . 'src' . DIRECTORY_SEPARATOR); 27 | 28 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 29 | require_once ROOT . 'vendor/autoload.php'; 30 | 31 | // load application config (error reporting etc.) 32 | require_once APP . 'config/config.php'; 33 | 34 | // load application class 35 | use Mvc\Core\Router; 36 | 37 | // start the application 38 | $app = new Router(); 39 | -------------------------------------------------------------------------------- /app-mvc5/src/view/_templates/footer.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | Find MINI3 on GitHub. 4 | If you like the mini3 project, support it by using Rackspace as your hoster [affiliate link]. 5 |
6 |
7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-mvc5/src/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <?=APP_TITTLE?> 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 |

16 | 17 |
18 | 19 | 29 |
30 | -------------------------------------------------------------------------------- /app-mvc5/src/view/customers/add.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /app-mvc5/src/view/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |

7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
21 |
22 |


23 | -------------------------------------------------------------------------------- /app-mvc5/src/view/customers/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 | 6 | Add Customer 7 | 8 |
9 |
10 | List of customers (data from model)
Amount of customers:
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
IDNameE-mailBirthdayACTIONS
id)) echo htmlspecialchars($customer->id, ENT_QUOTES, 'UTF-8'); ?>name)) echo htmlspecialchars($customer->name, ENT_QUOTES, 'UTF-8'); ?>email)) echo htmlspecialchars($customer->email, ENT_QUOTES, 'UTF-8'); ?>birthday)) echo htmlspecialchars($customer->birthday, ENT_QUOTES, 'UTF-8'); ?>deleteedit
34 |
35 |
36 | -------------------------------------------------------------------------------- /app-mvc5/src/view/error/index.php: -------------------------------------------------------------------------------- 1 |

2 |
3 |

This controller and/or action ( ) does not exists.

4 |
5 |



6 | -------------------------------------------------------------------------------- /app-mvc5/src/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

3 |

Home

4 |


5 | 6 |

This is the start homepage.

7 |
8 |




9 | 10 | -------------------------------------------------------------------------------- /docs/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | Options All -Indexes 3 | 4 | # ROUTER WWW Redirect. 5 | RewriteCond %{HTTP_HOST} !^www\. [NC] 6 | RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 7 | 8 | # ROUTER HTTPS Redirect 9 | RewriteCond %{HTTP:X-Forwarded-Proto} !https 10 | RewriteCond %{HTTPS} off 11 | RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 12 | 13 | # ROUTER URL Rewrite 14 | RewriteCond %{SCRIPT_FILENAME} !-f 15 | RewriteCond %{SCRIPT_FILENAME} !-d 16 | RewriteRule ^(.*)$ index.php?route=/$1 17 | -------------------------------------------------------------------------------- /docs/4mvc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/docs/4mvc1.png -------------------------------------------------------------------------------- /docs/4mvc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/docs/4mvc2.png -------------------------------------------------------------------------------- /docs/app-mvc4/0Estrutura.md: -------------------------------------------------------------------------------- 1 | ## Estrutura de Arquivos e diretórios 2 | 3 | Iremos criar a seguinte estrutura de diretórios e arquivos (vazios por enquanto) 4 | 5 | /var/www/html/app-mvc 6 | /src 7 | /config 8 | /Controller 9 | /Core 10 | /Libs 11 | /Model 12 | /view 13 | /public 14 | /db 15 | 16 | 17 | Detalhando: 18 | 19 | ```php 20 | /app-mvc 21 | /src 22 | bootstrap.php 23 | /config/ 24 | config.php 25 | /Controller/ 26 | CustomersController.php 27 | ErrorController.php 28 | HomeController.php 29 | /Core/ 30 | Model.php 31 | Route.php 32 | /Libs/ 33 | Helper.php 34 | /Model/ 35 | Customer.php 36 | Product.php 37 | /view/ 38 | /customers 39 | edit.php 40 | index.php 41 | /error 42 | index.php 43 | /home 44 | index.php 45 | /_templates 46 | footer.php 47 | header.php 48 | /db 49 | /migrations 50 | /seeds 51 | /public 52 | /css 53 | /images 54 | /js 55 | index.php 56 | .htaccess 57 | composer.json 58 | .htaccess 59 | ``` 60 | 61 | 62 | -------------------------------------------------------------------------------- /docs/app-mvc4/10.1css.md: -------------------------------------------------------------------------------- 1 | ## Criar o /var/www/html/app-mvc/public/css/custom.css 2 | 3 | ```css 4 | .navbar-dark .navbar-nav .nav-link { 5 | color: #a1e1ed; 6 | } 7 | .center-img { 8 | display: block; 9 | margin-left: auto; 10 | margin-right: auto; 11 | width: 20%; 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/app-mvc4/11.1Finalizando.md: -------------------------------------------------------------------------------- 1 | ## Finalizando e Executando o Aplicativo 2 | 3 | ### Crie o banco de dados 4 | 5 | ### Configure o banco no arquivo: src/config/config.php 6 | 7 | ### Criar no raiz do aplicativo os diretórios abaixo para as migrations: 8 | 9 | - mkdir db 10 | - mkdir db/migrations 11 | - mkdir db/seeds 12 | 13 | ### Criar o arquivo de configuração executando o comando no raiz do aplicativo: 14 | 15 | php vendor/bin/phinx init 16 | 17 | ### Editar e ajustar o banco de dados em (configure o ambiente development, em nosso caso): 18 | 19 | phinx.yml 20 | 21 | ### Para criar migration execute: 22 | 23 | vendor/robmorgan/phinx/bin/phinx create Customers 24 | 25 | ### Então edite o arquivo criado: 26 | 27 | db/migrations/20190821114033_customers.php 28 | 29 | O formato: YYYYMMDDHHMMSS_customers.php 30 | 31 | Alterar o método change() para que fique assim (exemplo): 32 | ```php 33 | public function change() 34 | { 35 | $this->table('customers') 36 | ->addColumn('name', 'string', ['limit' => 50]) 37 | ->addColumn('email', 'string', ['limit' => 50]) 38 | ->addColumn('birthday', 'date', ['null' => true]) 39 | ->addColumn('created', 'datetime',['default'=>'CURRENT_TIMESTAMP']) 40 | ->create(); 41 | } 42 | ``` 43 | ### Salve e executar o comando abaixo para criar a tabela: 44 | 45 | php vendor/robmorgan/phinx/bin/phinx migrate -e development 46 | 47 | ### Criar arquivo de Seed (popular tabela com registros): 48 | 49 | php vendor/bin/phinx seed:create Customers 50 | 51 | Gerará então o arquivo: 52 | 53 | db/seeds/Customers.php 54 | 55 | ### Editar o arquivo gerado e mudar que fique assim: 56 | ```php 57 | class Customers extends AbstractSeed 58 | { 59 | public function run() 60 | { 61 | $faker = Faker\Factory::create(); 62 | $data = []; 63 | for ($i = 0; $i < 50; $i++) { 64 | $data[] = [ 65 | 'name' => $faker->userName, 66 | 'email' => $faker->email, 67 | 'birthday' => $faker->date('Y-m-d'), 68 | 'created' => date('Y-m-d H:i:s'), 69 | ]; 70 | } 71 | 72 | $this->insert('customers', $data); 73 | } 74 | } 75 | ``` 76 | ### Para inserir os registros na tabela com seed execute: 77 | 78 | php vendor/bin/phinx seed:run -e development 79 | 80 | ## Atualizando o navegador 81 | 82 | http://localhost/app-mvc 83 | 84 | -------------------------------------------------------------------------------- /docs/app-mvc4/11.3Faker.md: -------------------------------------------------------------------------------- 1 | Resumo de exemplos de uso da biblioteca faker 2 | 3 | Para localização pt_BR, para gerar nomes em portuês, por exemplo: 4 | $faker = Faker\Factory::create('pt_BR'); 5 | 6 | $cpf = $faker->numberBetween($min = 10000000000, $max = 99999999999); 7 | $nome = addslashes($faker->name); 8 | $credito_liberado = $faker->regexify('[sn]'); 9 | $nascimento = $faker->date; 10 | $email = $faker->email; 11 | $user_id = $faker->numberBetween($min = 1, $max = 4); 12 | $quantidade = $faker->randomNumber($nbDigits = NULL, $strict = false); 13 | $preco_venda = $faker->numberBetween($min = 20, $max = 1200); 14 | 15 | $faker->randomNumber($nbDigits = NULL, $strict = false) // 79907610 16 | $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL) // 48.8932 17 | $faker->numberBetween($min = 1000, $max = 9000) // 8567 18 | $faker->regexify('[sn]'); // s ou n 19 | $faker->randomElement($array = array ('s','n')); 20 | $faker->randomLetter; 21 | $faker->regexify('[A-Z]+[a-z]{2,5}'); // 2 a 5 letras 22 | $faker->regexify('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}'); // sm0@y8k96a.ej 23 | $faker->randomElement($array = array ('a','b','c')); // 'b' 24 | print $faker->sentence($nbWords = 3, $variableNbWords = true); 25 | $faker->sentence($nbWords = 6, $variableNbWords = true); 26 | $faker->address; // rua, número e cep 27 | $faker->text; // Para grandes quantidades de texto 28 | $faker->sentence($nbWords = 6, $variableNbWords = true); 29 | $faker->text($maxNbChars = 200); 30 | $faker->title($gender = null|'male'|'female'); // 'Ms.' 31 | $faker->name($gender = null|'male'|'female'); // 'Dr. Zane Stroman' 32 | $faker->cityPrefix; 33 | $faker->state; 34 | $faker->stateAbbr; 35 | $faker->buildingNumber; 36 | $faker->city; 37 | $faker->streetName; 38 | $faker->streetAddress; 39 | $faker->postcode; 40 | $faker->country; 41 | $faker->PhoneNumber; 42 | $faker->company; 43 | $faker->date($format = 'Y-m-d', $max = 'now'); 44 | $faker->time($format = 'H:i:s', $max = 'now'); 45 | $faker->freeEmail; 46 | $faker->password; 47 | $faker->domainName; 48 | $faker->url; 49 | $faker->ipv4; 50 | $faker->macAddress; 51 | $faker->creditCardType; 52 | $faker->creditCardNumber; 53 | $faker->creditCardExpirationDateString; 54 | $faker->hexcolor; 55 | $faker->colorName; 56 | $faker->fileExtension; 57 | $faker->mimeType; 58 | $faker->locale; 59 | $faker->countryCode; 60 | $faker->randomHtml(2,3); 61 | 62 | https://github.com/fzaninotto/Faker 63 | -------------------------------------------------------------------------------- /docs/app-mvc4/11.4Woops.md: -------------------------------------------------------------------------------- 1 | ## Pacote para tratamento de erros - Whoops 2 | 3 | Whoops é uma pequena biblioteca, disponível como um pacote para Composer (https://packagist.org/packages/filp/whoops e https://github.com/filp/whoops), que ajuda a lidar com erros e exceções em seus projetos PHP. 4 | 5 | Lidando com erros de uma maneira que faz sentido para o que você está fazendo. 6 | 7 | ### Os principais recursos desta biblioteca são: 8 | • Página detalhada e intuitiva para erros e exceções 9 | • Visualização de código para todos os frames 10 | • Foco na análise de erro/exceção através do uso de middleware/manipuladores simples e personalizados 11 | • Suporte para solicitações JSON e AJAX 12 | • Fornecedores incluídos para projetos Silex e Zend por meio dos fornecedores incluídos no pacote e incluídos como parte do core do Laravel 4 13 | • Base de código limpa, compacta e testada, sem dependências extras 14 | 15 | Você diz ao Whoops quais manipuladores deseja usar (você pode escolher entre os manipuladores incluídos ou fazer o seu próprio), e se algo acontecer, todos os manipuladores recebem, na ordem, uma chance de fazer alguma coisa - isso pode ser qualquer coisa erro (Whoops torna mais fácil extrair informações significativas de um erro ou exceção), para exibir telas de erros úteis (com o PrettyPageHandler integrado, que oferece a aparência legal da página padrão). 16 | 17 | ### Algumas configurações 18 | No application/bootstrap.php 19 | 20 | /** 21 | * Register the error handler 22 | */ 23 | $whoops = new \Whoops\Run; 24 | 25 | if (ENVIRONMENT !== 'production') { 26 | // Configure the PrettyPageHandler: 27 | $errorPage = new Whoops\Handler\PrettyPageHandler(); 28 | 29 | $errorPage->setPageTitle("Algo errado aqui!"); // Set the page's title 30 | $errorPage->setEditor("sublime"); // Set the editor used for the "Open" link 31 | // Algumas informações extras 32 | $errorPage->addDataTable("Informações Extras", array( 33 | "stuff" => 123, 34 | "foo" => "bar", 35 | "useful_id" => "baloney" 36 | )); 37 | } else { 38 | $whoops->pushHandler(function($e){ 39 | echo 'Todo: Friendly error page and send an email to the developer'; 40 | }); 41 | } 42 | 43 | $whoops->pushHandler($errorPage); 44 | $whoops->register(); 45 | 46 | throw new RuntimeException("Verifique detalhes!"); 47 | 48 | Comente a linha acima e quando acontecer algum erro no aplicativo o whoops mostrará sua página de erros bem rica em informações, com o erro e muito mais. 49 | 50 | ### Referências 51 | https://github.com/filp/whoops 52 | https://code.tutsplus.com/tutorials/whoops-php-errors-for-cool-kids--net-32344 53 | https://github.com/PatrickLouys/no-framework-tutorial 54 | -------------------------------------------------------------------------------- /docs/app-mvc4/12Namespaces.md: -------------------------------------------------------------------------------- 1 | ## Vejamos agora os namespaces 2 | 3 | Veja que foi definido no composer.json o namespace Mvc apontando para a pasta src 4 | 5 | Mvc\\" : "src/" 6 | 7 | Na pasta application temos algumas pastas contendo classes: 8 | ```php 9 | /Controller 10 | /Core 11 | /Libs 12 | /Model 13 | ``` 14 | As classes da pasta src/Controller usam o namespace: 15 | 16 | namespace Mvc\Controller; 17 | 18 | E também usam: 19 | 20 | use Mvc\Model\Customer; // Para o respectivo model 21 | 22 | As classes da pasta src/Core usam o namespace: 23 | 24 | namespace Mvc\Core; 25 | 26 | Sendo que a classe Model também usa: 27 | 28 | use PDO; 29 | 30 | As classes da pasta src/Libs usam o namespace: 31 | 32 | namespace Mvc\Libs; 33 | 34 | As classes da pasta src/Model usam o namespace: 35 | 36 | namespace Mvc\Model; 37 | 38 | E também usam, todas elas: 39 | 40 | use Mvc\Core\Model; // Que a classe base dos models 41 | -------------------------------------------------------------------------------- /docs/app-mvc4/13BootStrap4.md: -------------------------------------------------------------------------------- 1 | ## Instalação do BootStrap 4 2 | 3 | Originalmente o aplicativo não vem com o BootStrap, mas com um CSS simples. 4 | 5 | Então troquei o css existente pelo BootStrap4. Isso no header.php, usando CDN. 6 | ```html 7 | 9 | 10 | ``` 11 | 12 | Criei um custom.css para customizações do BootStrap4. 13 | 14 | public/css/custom.css 15 | 16 | ```css 17 | .navbar-dark .navbar-nav .nav-link { 18 | color: #a1e1ed; 19 | } 20 | ``` 21 | 22 | Então fiz as devidas alterações das classes, basicamente nos forms e tables de: 23 | 24 | src/view/customers/edit.php e index.php 25 | 26 | Que é a nossa view com forms e tables. 27 | -------------------------------------------------------------------------------- /docs/app-mvc4/1composer.json.md: -------------------------------------------------------------------------------- 1 | ## Criação do app-mvc/composer.json 2 | 3 | Criar o arquivo 4 | composer.json 5 | 6 | Na pasta raiz do aplicativo, contendo: 7 | 8 | ```json 9 | { 10 | "name": "ribafs/app-mvc", 11 | "description": "APP-MVC - an extremely simple naked MVC PHP application", 12 | "type": "project", 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Panique", 17 | "email": "panique@firemail.de" 18 | }, 19 | { 20 | "name": "John Dias", 21 | "email": "joaodias@noctus.org" 22 | }, 23 | { 24 | "name": "Ribamar FS", 25 | "email": "ribafs@gmail.com" 26 | } 27 | ], 28 | "minimum-stability": "dev", 29 | "require": { 30 | "robmorgan/phinx": "dev-master", 31 | "fzaninotto/faker": "^1.9@dev", 32 | "filp/whoops": "^2.2@dev" 33 | }, 34 | "autoload": 35 | { 36 | "psr-4": 37 | { 38 | "Mvc\\" : "src/" 39 | } 40 | } 41 | } 42 | ``` 43 | 44 | Obs.: Veja que mantive os nomes dos autores originais, por gratidão e por conta da licença. 45 | -------------------------------------------------------------------------------- /docs/app-mvc4/2index.php.md: -------------------------------------------------------------------------------- 1 | ## index.php 2 | Criar a pasta 3 | /var/www/html/app-mvc/public 4 | 5 | E dentro dela o arquivo index.php 6 | 7 | Este é o ponto de entrada do aplicativo/entry point, chamado de front controller. Contendo as linhas abaixo: 8 | 9 | ```php 10 | $value) { 37 | 38 | // check if named parameters (':param') or anonymous parameters ('?') are used 39 | if (is_string($key)) { 40 | $keys[] = '/' . $key . '/'; 41 | } else { 42 | $keys[] = '/[?]/'; 43 | } 44 | 45 | // bring parameter into human-readable format 46 | if (is_string($value)) { 47 | $values[$key] = "'" . $value . "'"; 48 | } elseif (is_array($value)) { 49 | $values[$key] = implode(',', $value); 50 | } elseif (is_null($value)) { 51 | $values[$key] = 'NULL'; 52 | } 53 | } 54 | 55 | /* 56 | echo "
[DEBUG] Keys:
";
57 |         print_r($keys);
58 | 
59 |         echo "\n[DEBUG] Values: ";
60 |         print_r($values);
61 |         echo "
"; 62 | */ 63 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 64 | return $raw_sql; 65 | } 66 | } 67 | ``` 68 | 69 | 70 | -------------------------------------------------------------------------------- /docs/app-mvc4/7.1Model.php.md: -------------------------------------------------------------------------------- 1 | ## Implementando Controller, Model e Views para Customers 2 | 3 | Agora precisamos criar as views, controllers e models, no caso criarei apenas para customers. 4 | 5 | ### Criar Model.php 6 | 7 | Acessar a pasta /var/www/html/app-mvc/src/Core/ 8 | 9 | E dentro dela o arquivo 10 | Model.php 11 | 12 | Esta é a classe base dos models. Todos os models criados devem herdar dela. 13 | 14 | Com o conteúdo abaixo: 15 | 16 | ```php 17 | user_name ! 48 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 49 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 50 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 51 | 52 | // generate a database connection, using the PDO connector 53 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 54 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 55 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 56 | 57 | } 58 | } 59 | ``` 60 | 61 | 62 | -------------------------------------------------------------------------------- /docs/app-mvc4/8.1ErrorController.php.md: -------------------------------------------------------------------------------- 1 | ## Criação do controller Error 2 | 3 | Criar a apsta 4 | /var/www/html/app-mvc/src/Controller 5 | 6 | E dentro dela o arquivo 7 | 8 | ErrorController.php 9 | 10 | Contendo o código abaixo: 11 | 12 | ```php 13 |
16 |
17 |

This page ( controller / method) does not exist.

18 |
19 |



20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /docs/app-mvc4/9.2home-index.php.md: -------------------------------------------------------------------------------- 1 | ## Criar a view home/index 2 | 3 | Crie a pasta 4 | 5 | /var/www/html/app-mvc/src/view/home 6 | 7 | E dentro dela o arquivo 8 | 9 | index.php 10 | 11 | Contendo: 12 | 13 | ```php 14 |
15 |

16 |

Home

17 |


18 | 19 |

This is the start homepage.

20 |
21 |




22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/app-mvc4/9.3.1header.php.md: -------------------------------------------------------------------------------- 1 | ## Criar o header.php de _templates 2 | 3 | Criar a pasta 4 | 5 | /var/www/html/app-mvc/src/view/_templates 6 | 7 | E dentro dela o arquivo 8 | 9 | header.php 10 | 11 | Contendo: 12 | 13 | ```php 14 | 15 | 16 | 17 | 18 | <?=APP_TITTLE?> 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 |

34 | 35 |
36 | 46 |
47 | ``` 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/app-mvc4/9.3.2footer.php.md: -------------------------------------------------------------------------------- 1 | ## Criar o footer.php 2 | 3 | Acessar a pasta 4 | 5 | /var/www/html/app-mvc/src/view/_tempaltes 6 | 7 | E criar o arquivo 8 | 9 | footer.php 10 | 11 | Contendo: 12 | 13 | ```html 14 |
15 |
16 | Find MINI3 on GitHub. 17 | If you like the mini3 project, support it by using Rackspace as your hoster [affiliate link]. 18 |
19 |
20 | 21 | 22 | ``` 23 | 24 | ### Observação 25 | 26 | Caso compare com o original (mini3) verá que removi o javascript que retornava o total de registros, pois como estava funcionava somente com uma tabela e achei que não faria muita falta. 27 | -------------------------------------------------------------------------------- /docs/app-mvc4/9.4.1customers-edit.md: -------------------------------------------------------------------------------- 1 | ## Criação da view costomers/edit.php 2 | 3 | Criar a pasta 4 | 5 | /var/www/html/app-mvc/src/view/customers 6 | 7 | E dentro dela o arquivo 8 | 9 | edit.php 10 | 11 | Contendo: 12 | 13 | ```php 14 |
15 |

Customers

16 | 17 | 18 |
19 |

20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
31 |
32 |


33 | ``` 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/mini-fw6_tela.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/docs/mini-fw6_tela.png -------------------------------------------------------------------------------- /mini-fw5/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | composer.lock 3 | 4 | -------------------------------------------------------------------------------- /mini-fw5/.htaccess: -------------------------------------------------------------------------------- 1 | # This file redirect all requests ro public/ directory and enable mod_rewrite 2 | RewriteEngine on 3 | RewriteRule ^(.*) public/$1 [L] 4 | -------------------------------------------------------------------------------- /mini-fw5/README.md: -------------------------------------------------------------------------------- 1 | # mini-fw5 2 | 3 | ## Esta versão 4 | - Foi renomeada para mini-fw5 5 | - Trocou o CSS original pelo BootStrap 4 6 | - Criou a classe View() que substitui os requires nos métodos index(), edit() e add() do controller. 7 | - Renomeou a pasta application para src 8 | - Nesta versão foi testado e ajustado o suporte ao PostgreSQL 9 | - Adicionada a declaração em cada arquivo com função/método 10 | declare(strict_types = 1); 11 | 12 | - No início de cada arquivo para forçar a checagem de tipos em métodos/funções pelo PHP 13 | - Em caso de uso de tipo incompatível dispara: 14 | - Fatal error: Uncaught TypeError: 15 | - Agora temoms uma constante com o nome da aplicação que é adicionada no header.php para que apareça em todas as páginas. Configure em config/config.php: 16 | 17 | define('APP_TITTLE', 'Aplication Title'); 18 | 19 | ## Instalação 20 | 21 | Acesse a pasta e execute 22 | ´´´bash 23 | composer update 24 | ´´´ 25 | -------------------------------------------------------------------------------- /mini-fw5/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/mini-framework", 3 | "description": "MINI FRAMEWORK - an extremely simple MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "stable", 21 | "require": { 22 | 23 | }, 24 | "autoload": 25 | { 26 | "psr-4": 27 | { 28 | "Mini\\" : "src/" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mini-fw5/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /mini-fw5/public/css/custom.css: -------------------------------------------------------------------------------- 1 | .navbar-dark .navbar-nav .nav-link { 2 | color: #a1e1ed; 3 | } 4 | .center-img { 5 | display: block; 6 | margin-left: auto; 7 | margin-right: auto; 8 | width: 20%; 9 | } 10 | -------------------------------------------------------------------------------- /mini-fw5/public/images/mvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/mini-fw5/public/images/mvc.png -------------------------------------------------------------------------------- /mini-fw5/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | require __DIR__ . '/../src/bootstrap.php'; 22 | 23 | -------------------------------------------------------------------------------- /mini-fw5/src/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 34 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 35 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 36 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 37 | 38 | // generate a database connection, using the PDO connector 39 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 40 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 41 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 42 | 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /mini-fw5/src/Libs/Helper.php: -------------------------------------------------------------------------------- 1 | $value) { 27 | 28 | // check if named parameters (':param') or anonymous parameters ('?') are used 29 | if (is_string($key)) { 30 | $keys[] = '/' . $key . '/'; 31 | } else { 32 | $keys[] = '/[?]/'; 33 | } 34 | 35 | // bring parameter into human-readable format 36 | if (is_string($value)) { 37 | $values[$key] = ''' . $value . '''; // Before "'" 38 | } elseif (is_array($value)) { 39 | $values[$key] = implode(',', $value); 40 | } elseif (is_null($value)) { 41 | $values[$key] = 'NULL'; 42 | } 43 | } 44 | 45 | /* 46 | echo '
[DEBUG] Keys:
';
47 |         print_r($keys);
48 | 
49 |         echo '
[DEBUG] Values: '; 50 | print_r($values); 51 | echo '
'; 52 | */ 53 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 54 | return $raw_sql; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mini-fw5/src/View.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | // set a constant that holds the project's folder path, like "/var/www/html/mini-fw". 22 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 23 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 24 | 25 | // set a constant that holds the project's 'src' folder, like '/var/www/html/mini-fw/src'. 26 | define('APP', ROOT . 'src' . DIRECTORY_SEPARATOR); 27 | 28 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 29 | require_once ROOT . 'vendor/autoload.php'; 30 | 31 | // load application config (error reporting etc.) 32 | require_once APP . 'config/config.php'; 33 | 34 | // load application class 35 | use Mini\Core\Router; 36 | 37 | // start the application 38 | $app = new Router(); 39 | -------------------------------------------------------------------------------- /mini-fw5/src/view/_templates/footer.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | Find MINI3 on GitHub. 4 | If you like the mini3 project, support it by using Rackspace as your hoster [affiliate link]. 5 |
6 |
7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /mini-fw5/src/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <?=APP_TITTLE?> 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 |

16 | 17 |
18 | 19 | 29 |
30 | -------------------------------------------------------------------------------- /mini-fw5/src/view/customers/add.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /mini-fw5/src/view/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |

7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
21 |
22 |


23 | -------------------------------------------------------------------------------- /mini-fw5/src/view/customers/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 | 6 | Add Customer 7 | 8 |
9 |
10 | List of customers (data from model)
Amount of customers:
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
IDNameE-mailBirthdayACTIONS
id)) echo htmlspecialchars($customer->id, ENT_QUOTES, 'UTF-8'); ?>name)) echo htmlspecialchars($customer->name, ENT_QUOTES, 'UTF-8'); ?>email)) echo htmlspecialchars($customer->email, ENT_QUOTES, 'UTF-8'); ?>birthday)) echo htmlspecialchars($customer->birthday, ENT_QUOTES, 'UTF-8'); ?>deleteedit
34 |
35 |
36 | -------------------------------------------------------------------------------- /mini-fw5/src/view/error/index.php: -------------------------------------------------------------------------------- 1 |

2 |
3 |

This controller and/or action ( ) does not exists.

4 |
5 |



6 | -------------------------------------------------------------------------------- /mini-fw5/src/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

3 |

Home

4 |


5 | 6 |

This is the start homepage.

7 |
8 |




9 | 10 | -------------------------------------------------------------------------------- /mini-fw6/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | composer.lock 3 | 4 | -------------------------------------------------------------------------------- /mini-fw6/.htaccess: -------------------------------------------------------------------------------- 1 | # This file redirect all requests ro public/ directory and enable mod_rewrite 2 | RewriteEngine on 3 | RewriteRule ^(.*) public/$1 [L] 4 | -------------------------------------------------------------------------------- /mini-fw6/README.md: -------------------------------------------------------------------------------- 1 | # mini-fw6 2 | 3 | ## Esta versão 4 | - Usa duas tabelas, portanto praticamente duplica o código. Agora com customers e products 5 | - Foi renomeada para mini-fw6 6 | - Trocou o CSS original pelo BootStrap 4 7 | - Criou a classe View() que substitui os requires nos métodos index(), edit() e add() do controller. 8 | - Renomeou a pasta application para src 9 | - Nesta versão foi testado e ajustado o suporte ao PostgreSQL 10 | - Definida a constante CONTROLLER_DEFAULT e eliminado o controller e a view home, que de fato não tinha função 11 | - Adicionada a declaração em cada arquivo com função/método 12 | declare(strict_types = 1); 13 | 14 | No início de cada arquivo para forçar a checagem de tipos em métodos/funções pelo PHP 15 | 16 | Em caso de uso de tipo incompatível dispara: 17 | 18 | Fatal error: Uncaught TypeError: 19 | 20 | - Agora temoms uma constante com o nome da aplicação que é adicionada no header.php para que apareça em todas as páginas. Configure em config/config.php: 21 | 22 | define('APP_TITTLE', 'Aplication Title'); 23 | 24 | ## Instalação 25 | 26 | Acesse a pasta e execute 27 | ```bash 28 | composer update 29 | ``` 30 | -------------------------------------------------------------------------------- /mini-fw6/TODO: -------------------------------------------------------------------------------- 1 | Lembrando que o aplicativo base não tem qualquer dependência. 2 | 3 | Explicar com detalhes o sistema de rotas: 4 | - .htaccess (os dois) 5 | - public/index.php 6 | - application/bootstrap.php 7 | - application/Core/Router.php (aqui inserir paradas e comentar...) 8 | 9 | As 3 dependências/pacotes instalados são úteis, mas opcionais, podendo ser removidos. 10 | 11 | - Paginação (Dividir para view, controller e model) 12 | - Busca (Dividir para view, controller e model) 13 | - Usar o mais que puder de metdados dos SGBDs para tornar o aplicativo menos trabalhoso de codificar, puxando as informações diretamente do banco de dados usando os referidos metadados 14 | 15 | O código dos actions index, add e edit estão se repetindo, então é importante refatorar, criando uma estrutura de classes com herança ou interface. 16 | Como também acontece com o errorcontroller. 17 | 18 | Criar novas classes para usar: 19 | 20 | Front 21 | - form com bons recursos: input, select, radio, check, etc 22 | - table 23 | - links 24 | - images 25 | - modal 26 | - popups com Bootstrap 27 | - tooltip com BS 28 | - datagrid 29 | 30 | Arquivos de template: 31 | - header 32 | - footer 33 | 34 | 35 | Enriquecer aos poucos, por etapas, o mini-framework: 36 | - Usar os recursos do HTML5 no front 37 | - Usar boas validações no back com Filtros... 38 | - Paginação (separando em view - index, controller e model) 39 | - Busca (separando em view - index, controller e model) 40 | - Criar ferramenta de criação de código para o mini-framework, tipo o bake. Estudar o código gerado pelo bake/Cake para implementar no mini-fw. 41 | 42 | -------------------------------------------------------------------------------- /mini-fw6/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/mini-framework", 3 | "description": "MINI FRAMEWORK - an extremely simple MVC PHP application", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "stable", 21 | "require": { 22 | 23 | }, 24 | "autoload": 25 | { 26 | "psr-4": 27 | { 28 | "Mini\\" : "src/" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mini-fw6/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /mini-fw6/public/css/custom.css: -------------------------------------------------------------------------------- 1 | .navbar-dark .navbar-nav .nav-link { 2 | color: #a1e1ed; 3 | } 4 | .center-img { 5 | display: block; 6 | margin-left: auto; 7 | margin-right: auto; 8 | width: 20%; 9 | } 10 | 11 | .bg-gray{ 12 | background-color: #e8e3e3; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /mini-fw6/public/images/mvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/mini-fw6/public/images/mvc.png -------------------------------------------------------------------------------- /mini-fw6/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | require __DIR__ . '/../src/bootstrap.php'; 22 | 23 | -------------------------------------------------------------------------------- /mini-fw6/src/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 34 | // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! 35 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 36 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 37 | 38 | // TODO - Create a singleton classe to Model 39 | // generate a database connection, using the PDO connector 40 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 41 | $dsn = DB_TYPE . ':host=' . DB_HOST . ';port ='. DB_PORT . ';dbname=' . DB_NAME;// . $databaseEncodingenc; 42 | $this->db = new PDO($dsn , DB_USER, DB_PASS, $options); 43 | 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /mini-fw6/src/Libs/Helper.php: -------------------------------------------------------------------------------- 1 | $value) { 27 | 28 | // check if named parameters (':param') or anonymous parameters ('?') are used 29 | if (is_string($key)) { 30 | $keys[] = '/' . $key . '/'; 31 | } else { 32 | $keys[] = '/[?]/'; 33 | } 34 | 35 | // bring parameter into human-readable format 36 | if (is_string($value)) { 37 | $values[$key] = "' . $value . '"; // Before "'" 38 | } elseif (is_array($value)) { 39 | $values[$key] = implode(',', $value); 40 | } elseif (is_null($value)) { 41 | $values[$key] = 'NULL'; 42 | } 43 | } 44 | 45 | /* 46 | echo '
[DEBUG] Keys:
';
47 |         print_r($keys);
48 | 
49 |         echo '
[DEBUG] Values: '; 50 | print_r($values); 51 | echo '
'; 52 | */ 53 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 54 | return $raw_sql; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mini-fw6/src/View/CustomersView.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | * For more info about namespaces plase @see http://php.net/manual/en/language.namespaces.importing.php 13 | */ 14 | 15 | // set a constant that holds the project's folder path, like "/var/www/html/mini-fw". 16 | // DIRECTORY_SEPARATOR adds a slash to the end of the path 17 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 18 | 19 | // set a constant that holds the project's 'src' folder, like '/var/www/html/mini-fw/src'. 20 | define('APP', ROOT . 'src' . DIRECTORY_SEPARATOR); 21 | 22 | // This is the auto-loader for Composer-dependencies (to load tools into your project). 23 | require_once ROOT . 'vendor/autoload.php'; 24 | 25 | // load application config (error reporting etc.) 26 | require_once APP . 'config/config.php'; 27 | 28 | // load application class 29 | use Mini\Core\Router; 30 | 31 | // start the application 32 | $app = new Router(); 33 | -------------------------------------------------------------------------------- /mini-fw6/src/template/_templates/footer.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | Find MINI3 on GitHub. 4 | If you like the mini3 project, support it by using Rackspace as your hoster [affiliate link]. 5 |
6 |
7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /mini-fw6/src/template/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <?=APP_TITTLE?> 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 |

16 | 17 |
18 | 19 | 29 |
30 | -------------------------------------------------------------------------------- /mini-fw6/src/template/customers/add.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /mini-fw6/src/template/customers/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 |
6 |

7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
21 |
22 |


23 | -------------------------------------------------------------------------------- /mini-fw6/src/template/customers/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Customers

3 | 4 | 5 | 6 | Add Customer 7 | 8 |
9 |
10 | List of customers (data from model)
Amount of customers:
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
IDNameE-mailBirthdayACTIONS
id)) echo htmlspecialchars($customer->id, ENT_QUOTES, 'UTF-8'); ?>name)) echo htmlspecialchars($customer->name, ENT_QUOTES, 'UTF-8'); ?>email)) echo htmlspecialchars($customer->email, ENT_QUOTES, 'UTF-8'); ?>birthday)) echo htmlspecialchars($customer->birthday, ENT_QUOTES, 'UTF-8'); ?>deleteedit
34 |
35 |
36 | -------------------------------------------------------------------------------- /mini-fw6/src/template/error/index.php: -------------------------------------------------------------------------------- 1 |

2 |
3 |

This controller and/or action ( ) does not exists.

4 |
5 |



6 | -------------------------------------------------------------------------------- /mini-fw6/src/template/products/add.php: -------------------------------------------------------------------------------- 1 |
2 |

Products

3 | 4 | 5 |
6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /mini-fw6/src/template/products/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Product

3 | 4 | 5 |
6 |

7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
21 |
22 |


23 | -------------------------------------------------------------------------------- /mini-fw6/src/template/products/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Products

3 | 4 | 5 | 6 | Add Customer 7 | 8 |
9 |
10 | List of products (data from model)
Amount of products:
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
IDDescriptionUnityDateACTIONS
id)) echo htmlspecialchars($product->id, ENT_QUOTES, 'UTF-8'); ?>description)) echo htmlspecialchars($product->description, ENT_QUOTES, 'UTF-8'); ?>unity)) echo htmlspecialchars($product->unity, ENT_QUOTES, 'UTF-8'); ?>date)) echo htmlspecialchars($product->date, ENT_QUOTES, 'UTF-8'); ?>DeleteEdit
34 |
35 |
36 | -------------------------------------------------------------------------------- /mini-mvc/.htaccess: -------------------------------------------------------------------------------- 1 | # This file is - if you set up MINI correctly - not needed. 2 | # But, for fallback reasons (if you don't route your vhost to /public), it will stay here. 3 | RewriteEngine on 4 | RewriteRule ^(.*) public/$1 [L] 5 | -------------------------------------------------------------------------------- /mini-mvc/app/Controller/ErrorController.php: -------------------------------------------------------------------------------- 1 | user_name ! 33 | // Por exemplo, fetch mode FETCH_ASSOC retornaria resultados como este: $result["user_name] ! 34 | // @see http://www.php.net/manual/en/pdostatement.fetch.php 35 | $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); 36 | 37 | // definindo a codificação é diferente ao usar PostgreSQL 38 | if (DB_TYPE == "pgsql") { 39 | $databaseEncodingenc = " options='--client_encoding=" . DB_CHARSET . "'"; 40 | } else { 41 | $databaseEncodingenc = "; charset=" . DB_CHARSET; 42 | } 43 | 44 | // gerar uma conexão de banco de dados, usando o conector PDO 45 | // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ 46 | $this->db = new PDO(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME . $databaseEncodingenc, DB_USER, DB_PASS, $options); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mini-mvc/app/Libs/helper.php: -------------------------------------------------------------------------------- 1 | $value) { 25 | 26 | // checar se os parâmetros nomeados (':param') ou anonymous parameters ('?') são usados 27 | if (is_string($key)) { 28 | $keys[] = '/' . $key . '/'; 29 | } else { 30 | $keys[] = '/[?]/'; 31 | } 32 | 33 | // traga o parâmetro para o formato legível por humanos 34 | if (is_string($value)) { 35 | $values[$key] = "'" . $value . "'"; 36 | } elseif (is_array($value)) { 37 | $values[$key] = implode(',', $value); 38 | } elseif (is_null($value)) { 39 | $values[$key] = 'NULL'; 40 | } 41 | } 42 | 43 | /* 44 | echo "
[DEBUG] Keys:
";
45 |         print_r($keys);
46 | 
47 |         echo "\n[DEBUG] Values: ";
48 |         print_r($values);
49 |         echo "
"; 50 | */ 51 | 52 | $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); 53 | 54 | return $raw_sql; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mini-mvc/app/config/config.php: -------------------------------------------------------------------------------- 1 | 3 | Find MINI3 on GitHub. 4 | If you like the project, support it by using Rackspace as your hoster [affiliate link]. 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mini-mvc/app/view/_templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MINI MVC 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

Pequeno CRUD em PHP usando MVC

19 |


20 | 21 | 27 | -------------------------------------------------------------------------------- /mini-mvc/app/view/clientes/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Você está na View: application/view/clientes/edit.php (tudo nesta tela vem desse arquivo)

3 | 4 |
5 |

Editar um cliente

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /mini-mvc/app/view/error/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Controller não encontrado. Será mostrada quando uma página (= controller/method) não existir.

3 |
4 | -------------------------------------------------------------------------------- /mini-mvc/app/view/funcionarios/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Você está na View: app/view/funcionarios/edit.php (tudo nesta tela vem desse arquivo)

3 | 4 |
5 |

Editar um funcionario

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /mini-mvc/app/view/funcionarios/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Funcionários

3 |

Você está na View: application/view/funcionarios/index.php (tudo nesta tela vem desse arquivo)

4 | 5 |
6 |

Adicionar um funcionário

7 |
8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |
17 |

Total de funcionarios:

18 |

Total de funcionários (via AJAX)

19 |
20 |
21 | 22 |
23 |

Lista de funcionarios (dados do model)

24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
IDNomeCPFDELETEEDIT
id)) echo htmlspecialchars($funcionario->id, ENT_QUOTES, 'UTF-8'); ?>nome)) echo htmlspecialchars($funcionario->nome, ENT_QUOTES, 'UTF-8'); ?>obs)) echo htmlspecialchars($funcionario->obs, ENT_QUOTES, 'UTF-8'); ?>cpf)) echo htmlspecialchars($funcionario->cpf, ENT_QUOTES, 'UTF-8'); ?>ExcluirEditar
47 |
48 |
49 | -------------------------------------------------------------------------------- /mini-mvc/app/view/home/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Início

3 |

Você está na View: application/view/home/index.php

4 |

Em uma aplicação real esta pode ser a homepage inicial com conteúdo customizado ou então pode ser removida e tornar a inicial um dos outros.

5 |
6 | -------------------------------------------------------------------------------- /mini-mvc/app/view/produtos/edit.php: -------------------------------------------------------------------------------- 1 |
2 |

Você está na View: app/view/produtos/edit.php (tudo nesta tela vem desse arquivo)

3 | 4 |
5 |

Editar um produto

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 | 17 | -------------------------------------------------------------------------------- /mini-mvc/app/view/produtos/index.php: -------------------------------------------------------------------------------- 1 |
2 |

Produto

3 |

Você está na View: app/view/produtos/index.php (tudo nesta tela vem desse arquivo)

4 | 5 |
6 |

Adicionar um produto

7 |
8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |
17 |

Total de produtos:

18 |

Total de produtos (via AJAX)

19 |
20 |
21 | 22 |
23 |

Lista de produtos (dados do model)

24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
IDDescriçãoUnidadeExcluirAtualizar
id)) echo htmlspecialchars($produto->id, ENT_QUOTES, 'UTF-8'); ?>descricao)) echo htmlspecialchars($produto->descricao, ENT_QUOTES, 'UTF-8'); ?>unidade)) echo htmlspecialchars($produto->unidade, ENT_QUOTES, 'UTF-8'); ?>ExcluirEditar
46 |
47 |
48 | -------------------------------------------------------------------------------- /mini-mvc/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribafs/mini-mvc", 3 | "description": "MINI-MVC - An application created with mini3 mvc", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Panique", 9 | "email": "panique@firemail.de" 10 | }, 11 | { 12 | "name": "John Dias", 13 | "email": "joaodias@noctus.org" 14 | }, 15 | { 16 | "name": "Ribamar FS", 17 | "email": "ribafs@gmail.com" 18 | } 19 | ], 20 | "minimum-stability": "dev", 21 | "require": {}, 22 | "autoload": 23 | { 24 | "psr-4": 25 | { 26 | "Mini\\" : "app/" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mini-mvc/divulgacao: -------------------------------------------------------------------------------- 1 | Aplicando MVC em seu aplicativo PHP 2 | A arquitetura de software MVC atualmente dominou os grandes softwares em PHP, os frameworks, os CMS, etc. Ela anda junto com autoload, namespace, composer e rotas e isso torna mais complexo seu entendimento por quem está iniciando em PHP. 3 | Eu passei vários anos programando em php procedural. Aprendi o básico da orientação a objetos mas implementar MVC em um aplicativo meu deu bastante trabalho. 4 | Até que encontrei um pequneo aplicativo no GitHub que me permitiu entender a aplicação do MVC e cia em um aplicativo. Traduzi, alterei, simplifiquei algumas coisas e criei e publiquei o repositório mini-mvc, com a intenção de colaborar com quem também ainda tem dificuldade de entender o uso do MVC. 5 | https://github.com/ribafs/mini-mvc 6 | 7 | -------------------------------------------------------------------------------- /mini-mvc/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Necessary to prevent problems when using a controller named "index" and having a root index.php 2 | # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html 3 | Options -MultiViews 4 | 5 | # Activates URL rewriting (like myproject.com/controller/action/1/2/3) 6 | RewriteEngine On 7 | 8 | # Prevent people from looking directly into folders 9 | Options -Indexes 10 | 11 | # If the following conditions are true, then rewrite the URL: 12 | # If the requested filename is not a directory, 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | # and if the requested filename is not a regular file that exists, 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | # and if the requested filename is not a symbolic link, 17 | RewriteCond %{REQUEST_FILENAME} !-l 18 | # then rewrite the URL in the following way: 19 | # Take the whole request filename and provide it as the value of a 20 | # "url" query parameter to index.php. Append any query string from 21 | # the original URL as further query parameters (QSA), and stop 22 | # processing this .htaccess file (L). 23 | RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 24 | -------------------------------------------------------------------------------- /mini-mvc/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | font-size: 14px; 4 | color: #454545; 5 | } 6 | .logo { 7 | width: 200px; 8 | height: 200px; 9 | /* this is a real image encoded via base64 text, an awesome technology! check https://varvy.com/pagespeed/base64-images.html for more info */ 10 | background: url('data:image'); 11 | margin: 20px 30px; 12 | } 13 | .navigation { 14 | margin-left: 33px; 15 | } 16 | .navigation a { 17 | display: inline-block; 18 | padding: 8px 12px; 19 | border-radius: 3px; 20 | text-decoration: none; 21 | font-size: 12px; 22 | text-transform: uppercase; 23 | font-weight: bold; 24 | border: 1px solid #454545; 25 | color: #454545; 26 | background: transparent; 27 | } 28 | .navigation a:hover { 29 | background: #454545; 30 | color: #fff; 31 | } 32 | .container { 33 | border: 1px solid #454545; 34 | border-radius: 3px; 35 | padding: 20px; 36 | margin: 33px; 37 | } 38 | .container a { 39 | color: #454545; 40 | } 41 | .container table { 42 | font-size: 11px; 43 | margin-top: 20px; 44 | } 45 | .container table thead td { 46 | background-color: #f5f5f5; 47 | padding: 4px 10px; 48 | } 49 | .container table tbody td { 50 | padding: 4px 10px; 51 | } 52 | .container .box { 53 | border-top: 1px solid #ddd; 54 | padding-top: 10px; 55 | margin-top: 30px; 56 | } 57 | .container input { 58 | background-color: #f5f5f5; 59 | border: 0; 60 | padding: 5px 10px; 61 | } 62 | .container input[type="submit"] { 63 | background-color: #ccc; 64 | cursor: pointer; 65 | } 66 | .container input[type="submit"]:hover { 67 | background-color: #222; 68 | color: #fff; 69 | } 70 | .container button { 71 | background-color: #ccc; 72 | border: 0; 73 | padding: 5px 10px; 74 | cursor: pointer; 75 | } 76 | .container button:hover { 77 | background-color: #222; 78 | color: #fff; 79 | } 80 | .footer { 81 | border-radius: 3px; 82 | padding: 20px; 83 | margin: 33px; 84 | text-align: right; 85 | font-size: 11px; 86 | } 87 | .footer a { 88 | color: #454545; 89 | } 90 | -------------------------------------------------------------------------------- /mini-mvc/public/img/demo-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ribafs/mini-framework/1bca13f3435730db8899eb749a5c5784cfb20aee/mini-mvc/public/img/demo-image.png -------------------------------------------------------------------------------- /mini-mvc/public/index.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * Para mais informações sobre namespaces @see http://php.net/manual/en/language.namespaces.importing.php 19 | */ 20 | 21 | // definir uma constante que mantenha o caminho da pasta do projeto, como "/var/www/html/". 22 | // DIRECTORY_SEPARATOR adiciona uma para o final do path 23 | define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); 24 | // definir uma constante que mantém a pasta "application" do projeto, como "/var/www/html/projeto/application". 25 | define('APP', ROOT . 'app' . DIRECTORY_SEPARATOR); 26 | 27 | // Este é o auto-loader para dependências do Composer (para carregar ferramentas em seu projeto). 28 | require ROOT . 'vendor/autoload.php'; 29 | 30 | // carregar configuração do aplicativo (error reporting etc.) 31 | require APP . 'config/config.php'; 32 | 33 | // carregar a classe application 34 | use Mini\Core\Application; 35 | 36 | // iniciar a app 37 | $app = new Application(); 38 | -------------------------------------------------------------------------------- /mini-mvc/public/js/application.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // just a super-simple JS demo 4 | 5 | var demoHeaderBox; 6 | 7 | // simple demo to show create something via javascript on the page 8 | if ($('#javascript-header-demo-box').length !== 0) { 9 | demoHeaderBox = $('#javascript-header-demo-box'); 10 | demoHeaderBox 11 | .hide() 12 | .text('Hello from JavaScript! This line has been added by public/js/application.js') 13 | .css('color', 'green') 14 | .fadeIn('slow'); 15 | } 16 | 17 | // if #javascript-ajax-button exists 18 | if ($('#javascript-ajax-button').length !== 0) { 19 | 20 | $('#javascript-ajax-button').on('click', function(){ 21 | 22 | // send an ajax-request to this URL: current-server.com/songs/ajaxGetStats 23 | // "url" is defined in views/_templates/footer.php 24 | $.ajax(url + "/songs/ajaxGetStats") 25 | .done(function(result) { 26 | // this will be executed if the ajax-call was successful 27 | // here we get the feedback from the ajax-call (result) and show it in #javascript-ajax-result-box 28 | $('#javascript-ajax-result-box').html(result); 29 | }) 30 | .fail(function() { 31 | // this will be executed if the ajax-call had failed 32 | }) 33 | .always(function() { 34 | // this will ALWAYS be executed, regardless if the ajax-call was success or not 35 | }); 36 | }); 37 | } 38 | 39 | }); 40 | -------------------------------------------------------------------------------- /mini-mvc/vendor/autoload.php: -------------------------------------------------------------------------------- 1 | array($baseDir . '/app'), 10 | ); 11 | -------------------------------------------------------------------------------- /mini-mvc/vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 27 | if ($useStaticLoader) { 28 | require_once __DIR__ . '/autoload_static.php'; 29 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInit2847e8ead9f2a445cf29cd5bf8bc4416::getInitializer($loader)); 31 | } else { 32 | $map = require __DIR__ . '/autoload_namespaces.php'; 33 | foreach ($map as $namespace => $path) { 34 | $loader->set($namespace, $path); 35 | } 36 | 37 | $map = require __DIR__ . '/autoload_psr4.php'; 38 | foreach ($map as $namespace => $path) { 39 | $loader->setPsr4($namespace, $path); 40 | } 41 | 42 | $classMap = require __DIR__ . '/autoload_classmap.php'; 43 | if ($classMap) { 44 | $loader->addClassMap($classMap); 45 | } 46 | } 47 | 48 | $loader->register(true); 49 | 50 | return $loader; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mini-mvc/vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | 11 | array ( 12 | 'Mini\\' => 5, 13 | ), 14 | ); 15 | 16 | public static $prefixDirsPsr4 = array ( 17 | 'Mini\\' => 18 | array ( 19 | 0 => __DIR__ . '/../..' . '/app', 20 | ), 21 | ); 22 | 23 | public static function getInitializer(ClassLoader $loader) 24 | { 25 | return \Closure::bind(function () use ($loader) { 26 | $loader->prefixLengthsPsr4 = ComposerStaticInit2847e8ead9f2a445cf29cd5bf8bc4416::$prefixLengthsPsr4; 27 | $loader->prefixDirsPsr4 = ComposerStaticInit2847e8ead9f2a445cf29cd5bf8bc4416::$prefixDirsPsr4; 28 | 29 | }, null, ClassLoader::class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mini-mvc/vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | [] 2 | --------------------------------------------------------------------------------