Skip to content

Commit f42c99e

Browse files
committed
Evolve it to the next level
1 parent 229bae2 commit f42c99e

30 files changed

Lines changed: 690 additions & 166 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.env
1+
vendor
2+
.DS_Store

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.2.2-apache
1+
FROM php:7.4-apache
22

33
RUN docker-php-ext-install mysqli pdo pdo_mysql
44
RUN a2enmod rewrite

README.md

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,3 @@
11
# php-micro
22

3-
Minimalistic MVC-Framework
4-
5-
6-
## Getting started
7-
8-
### Configuration
9-
10-
Copy `index.php` and `.htaccess` into your project directory and place a file named `config.php` next to it.
11-
12-
Specify your database connection and routes as follows:
13-
14-
```php
15-
<?php return [
16-
'db' => [
17-
'host' => getenv('DB_HOST'),
18-
'name' => getenv('DB_NAME'),
19-
'user' => getenv('DB_USER'),
20-
'password' => getenv('DB_PASSWORD')
21-
],
22-
'routes' => [
23-
'/' => 'views/index/index.php',
24-
'/artists' => 'views/artists/index.php',
25-
'/artists/:id' => 'views/artists/show.php'
26-
]
27-
];
28-
```
29-
30-
If your host doesn't allow for adding environment variables, you could of course hardcode your db credentials. Note that you should not maintain production keys in version control.
31-
32-
### Example page
33-
34-
Query database and render results to the output stream
35-
36-
```php
37-
<?php
38-
$stmt = $db->query('SELECT * FROM artists');
39-
$rows = $stmt->fetchAll();
40-
?>
41-
<h1>Artists</h1>
42-
<?php foreach($rows as $index => $row): ?>
43-
<h5><a href="<?= $base_url ?>/artists/<?= $row['id']; ?>"><?= $row['name']; ?></a></h5>
44-
<?php endforeach; ?>
45-
```
3+
Minimalist web framework inspired by express.js

composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "benignware/micro",
3+
"version": "0.0.1",
4+
"description": "Minimalist web framework",
5+
"license": "MIT",
6+
"require": {
7+
"php": ">=7.4"
8+
},
9+
"autoload": {
10+
"files": [
11+
"index.php"
12+
]
13+
}
14+
}

config.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

docker-compose.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,30 @@ services:
44
db:
55
image: mysql:5.7
66
environment:
7-
MYSQL_ROOT_PASSWORD: root
7+
MYSQL_ROOT_PASSWORD: secret
88
MYSQL_DATABASE: database
9-
MYSQL_USER: root
10-
MYSQL_PASSWORD: root
11-
ports:
12-
- "9906:3306"
9+
MYSQL_USER: user
10+
MYSQL_PASSWORD: secret
1311
volumes:
1412
- data:/var/lib/mysql
1513
restart: always
1614
web:
1715
environment:
18-
DB_HOST: ${DB_HOST}
19-
DB_NAME: ${DB_NAME}
20-
DB_USER: ${DB_USER}
21-
DB_PASSWORD: ${DB_PASSWORD}
16+
DB_HOST: db
17+
DB_NAME: database
18+
DB_USER: user
19+
DB_PASSWORD: secret
2220
build: .
2321
depends_on:
2422
- db
2523
links:
2624
- db
2725
volumes:
28-
- ./:/var/www/html
26+
- .:/usr/local/lib/php-micro
27+
- ./example/:/var/www/html
2928
ports:
3029
- "3000:80"
31-
stdin_open: true
32-
tty: true
30+
working_dir: /var/www/html
3331
phpmyadmin:
3432
image: phpmyadmin/phpmyadmin
3533
depends_on:
@@ -39,9 +37,21 @@ services:
3937
environment:
4038
PMA_HOST: db
4139
PMA_PORT: 3306
40+
PMA_ARBITRARY: 1
4241
ports:
4342
- '3001:80'
4443
volumes:
4544
- /sessions
45+
composer:
46+
image: composer
47+
command: install
48+
working_dir: /var/www/html
49+
depends_on:
50+
- web
51+
volumes:
52+
- .:/usr/local/lib/php-micro
53+
- ./example/composer.json:/var/www/html/composer.json
54+
- ./example/composer.lock:/var/www/html/composer.lock
55+
- ./example/vendor:/var/www/html/vendor
4656
volumes:
4757
data:
File renamed without changes.

example/assets/main.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
html,
2+
body {
3+
height: 100%;
4+
}
5+
6+
body {
7+
display: flex;
8+
min-height: 100vh;
9+
flex-direction: column;
10+
}
11+
12+
main {
13+
margin-top: 56px;
14+
display: flex;
15+
flex: 1;
16+
}
17+
18+
.form-signin {
19+
width: 100%;
20+
max-width: 330px;
21+
padding: 15px;
22+
margin: auto;
23+
}
24+
25+
.form-signin .checkbox {
26+
font-weight: 400;
27+
}
28+
29+
.form-signin .form-control {
30+
position: relative;
31+
box-sizing: border-box;
32+
height: auto;
33+
padding: 10px;
34+
font-size: 16px;
35+
}
36+
37+
.form-signin .form-control:focus {
38+
z-index: 2;
39+
}
40+
41+
.form-signin input[type="email"] {
42+
margin-bottom: -1px;
43+
border-bottom-right-radius: 0;
44+
border-bottom-left-radius: 0;
45+
}
46+
47+
.form-signin input[type="password"] {
48+
margin-bottom: 10px;
49+
border-top-left-radius: 0;
50+
border-top-right-radius: 0;
51+
}
52+
53+
54+
.form-license .form-options .row:first-child button {
55+
display: none;
56+
}

example/composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "benignware/php-micro-test",
3+
"version": "1.0.0",
4+
"description": "Test config for php-micro",
5+
"homepage": "http://github.com/benignware/php-micro",
6+
"authors": [
7+
{
8+
"name": "Rafael Nowrotek",
9+
"email": "mail@benignware.com",
10+
"homepage": "https://github.com/benignware"
11+
}
12+
],
13+
"repositories": [{
14+
"type": "path",
15+
"url": "/usr/local/lib/php-micro"
16+
}],
17+
"require": {
18+
"php": ">=7.4",
19+
"benignware/micro": "*"
20+
}
21+
}

example/composer.lock

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)