Skip to content

Commit d9a5a8e

Browse files
author
AFN
committed
Huge Update
Basic features completed.
1 parent e221bfb commit d9a5a8e

File tree

986 files changed

+217248
-628
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

986 files changed

+217248
-628
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.md

Lines changed: 2 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,4 @@
11
# afn-php-framework
2-
AFN Custom PHP Framework
2+
AFN PHP+MySQL Framework
33

4-
You need to install docker to run project.
5-
6-
7-
## INSTALL
8-
9-
Install docker and docker-compose.
10-
11-
Start docker.
12-
13-
Create a folder named ```Sites``` inside user folder.
14-
15-
Create another folder named ```framework``` inside ```Sites```.
16-
17-
Copy all files to ```framework```.
18-
19-
Go to project folder with Terminal:
20-
21-
```
22-
$ cd Users/you/Sites/framework
23-
```
24-
Enter this command:
25-
```
26-
$ docker-compose up
27-
```
28-
29-
30-
## RE-INSTALL AFTER EDITING
31-
32-
Go to project folder:
33-
```
34-
$ cd Users/you/Sites/framework
35-
```
36-
Enter this command:
37-
```
38-
$ docker-compose up -d --build
39-
```
40-
41-
## HOW TO CREATE NEW PAGE
42-
43-
Firstly call View class:
44-
```
45-
$view = new View();
46-
```
47-
48-
After that, you should imply the path of view file(you don't need to enter full path. Ex: index Ex2: alerts/successful):
49-
```
50-
$view->view_file = "index";
51-
```
52-
53-
If you want to add other template files to your actual page, you should push file paths into array object of add_files as the following:
54-
```
55-
$view->add_files = [
56-
'header' => 'header_fixed',
57-
'alert_box' => 'alert_box_error'
58-
];
59-
```
60-
61-
You can use new_entry function to add data. First parameter is type of your data which defines regex and second paramter is array of your data. Your data should be entered as a array value and it should have an unique identifier as a array key.
62-
```
63-
$view->new_entry(1, [
64-
'test' => 'This was a test data!',
65-
'test2' => 'Lorem ipsum dolor. Sit amet orci. In et molestie interdum vitae libero varius felis nunc pellentesque ut venenatis interdum volutpat vitae amet nec leo orci vulputate massa.',
66-
'test3' => 'Lorem ipsum dolor. Sit amet orci. In et molestie interdum vitae libero varius felis nunc pellentesque ut venenatis interdum volutpat vitae amet nec leo orci vulputate massa.',
67-
]);
68-
```
69-
70-
You can add loops to array of your data. It provides to push more than data. You have to give an unique name for each loop.
71-
```
72-
$view->new_entry(1, [
73-
'loop_1_1' => [
74-
'test' => 'I will',
75-
'test2' => 'love',
76-
'test3' => 'you',
77-
],
78-
'loop_1_2' => [
79-
'test' => 'until',
80-
'test2' => 'I',
81-
'test3' => 'die',
82-
],
83-
]);
84-
```
85-
86-
You can use new_entry function at choice, so you don't have to push all your data in one go.
87-
88-
Start view processes and echo view page:
89-
```
90-
echo $view->generate_markup();
91-
```
92-
93-
## HINTS
94-
95-
- To access web site with browser, go to http://localhost or http://localhost:[port].
96-
97-
- Change port for different projects in docker-compose.yml as the following:
98-
ports:
99-
```
100-
- "9142:80"
101-
- "4254:443"
102-
```
103-
104-
- To run project:
105-
```
106-
$ cd User/you/Sites/framework
107-
$ docker-compose up -d
108-
```
109-
110-
- To access web directory:
111-
```
112-
$ cd Users/you/Sites/framework/www
113-
```
114-
115-
- To access MySQL database:
116-
```
117-
Host: 127.0.0.1:3306 (127.0.0.1 for MySQL Workbench)
118-
Username: root
119-
Password: test
120-
```
121-
To access MySQL db from localhost, enter docker inspect ```task_db_1``` on Terminal and find IPAddress and then change 127.0.0.1 with it
122-
123-
- To get container ip:
124-
```
125-
$ docker inspect <container-id>
126-
```
127-
128-
- To add a php extension or an apache module or others to project, edit Dockerfile inside
129-
```Users/you/Sites/framework/server```.
130-
131-
- To access server command line(change <container-id> into id of the container which contain centos 7):
132-
```
133-
$ docker exec -it <container-id> /bin/bash
134-
```
135-
136-
- To view all containers:
137-
```
138-
$ docker-compose ps
139-
```
4+
[Go to official website to test framework and read documentation.](http://www.alifuatnumanoglu.com/php-framework)

app/autoload.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,69 @@
11
<?php
22

3-
/*
3+
/**
44
* This file was created by AFN.
55
* If you think that there is a notifiable issue
66
* affecting the file, please contact AFN.
7-
7+
* @author AFN <[email protected]>
88
*/
99

10-
// determine ROOT_DIR if it is not defined
11-
if(!defined('ROOT_DIR')) {
10+
/**
11+
* Autoload
12+
*
13+
* @package AFN-PHP-FRAMEWORK
14+
*/
15+
16+
// Determine ROOT_DIR if it is not defined
17+
if (!defined('ROOT_DIR')) {
1218
define('ROOT_DIR', realpath(__DIR__ . '/..'));
1319
}
1420

15-
// define default settings as global variable
21+
// Define default settings as global variable
1622
$GLOBALS['settings'] = require_once ROOT_DIR . '/config/app.php';
23+
$GLOBALS['captchas'] = require_once ROOT_DIR . '/config/captchas.php';
1724

1825
spl_autoload_register(function ($class) {
1926

20-
// project-specific namespace prefix
27+
// Project-specific namespace prefix
2128
$prefix = 'AFN\\';
2229

23-
// check if ROOT_DIR is not defined
24-
// base directory for the namespace prefix
25-
if(!defined('ROOT_DIR')) {
30+
// Check if ROOT_DIR is not defined
31+
// Base directory for the namespace prefix
32+
if (!defined('ROOT_DIR')) {
2633
$base_dir = realpath(__DIR__ . '/..') . '/';
2734
} else {
2835
$base_dir = ROOT_DIR . '/';
2936
}
3037

31-
// does the class use the namespace prefix?
38+
// Does the class use the namespace prefix?
3239
$len = strlen($prefix);
33-
if(strncmp($prefix, $class, $len) !== 0) {
34-
// no, move to the next registered autoloader
40+
if (strncmp($prefix, $class, $len) !== 0) {
41+
// No, move to the next registered autoloader
3542
return;
3643
}
3744

38-
// get the relative class name
45+
// Get the relative class name
3946
$relative_class = substr($class, $len);
4047

41-
// get everything before the class name
48+
// Get everything before the class name
4249
$non_class = substr($relative_class, 0, strrpos($relative_class, '\\'));
4350

44-
// make lowercase non-class string
51+
// Make lowercase non-class string
4552
$non_class_lower = strtolower($non_class);
4653

47-
// get the plain class name
54+
// Get the plain class name
4855
$plain_class = substr($relative_class, strrpos($relative_class, '\\') + 1);
4956

50-
// compound the non-class string and the plain class
57+
// Compound the non-class string and the plain class
5158
$last_class = $non_class_lower . "/" . $plain_class;
5259

53-
// replace the namespace prefix with the base directory, replace namespace
60+
// Replace the namespace prefix with the base directory, replace namespace
5461
// separators with directory separators in the relative class name, append
5562
// with .php
5663
$file = $base_dir . str_replace('\\', '/', $last_class) . '.php';
5764

58-
// if the file exists, require it
59-
if(file_exists($file)) {
65+
// If the file exists, require it
66+
if (file_exists($file)) {
6067
require $file;
6168
}
6269
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* This file was created by AFN.
5+
* If you think that there is a notifiable issue
6+
* affecting the file, please contact AFN.
7+
* @author AFN <[email protected]>
8+
*/
9+
10+
namespace AFN\App\Controllers;
11+
12+
use AFN\App\Core\Controller;
13+
14+
/**
15+
* Class DefaultController
16+
* Default page
17+
*
18+
* @package AFN-PHP-FRAMEWORK
19+
*/
20+
class DefaultController extends Controller
21+
{
22+
23+
/**
24+
* Stores view class
25+
* @var object $view
26+
*/
27+
public $view;
28+
29+
public function __construct()
30+
{
31+
$this->view = new \AFN\App\Core\View();
32+
$this->secure = new \AFN\App\Core\Secure();
33+
}
34+
35+
/**
36+
* Displays default page
37+
*/
38+
public function display()
39+
{
40+
$this->view->viewFile = "main";
41+
$this->view->newEntry(1, ["navbar_home_active" => "active"]);
42+
echo $this->view->generateMarkup();
43+
}
44+
}

0 commit comments

Comments
 (0)