summaryrefslogtreecommitdiff
path: root/README.md
blob: ee9a742e9add31fbcd4220c05231c9a38c13b806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# x-anom 
(another MVC framework)

An open-source, fast, super-light, secure, full-featured, modern, easy to setup, easy to learn,
highly extendable, php 8+, OOP MVC framework for the php-developer.



## why anom?

* fast and secure
* modern, super light and elegant
* easy to setup, to learn, to optimize
* extendable + TODO: scalable
* ready for any server environment (metal, VM, container)



## requirements

* php 8.1+
* web server
* latest MySQL or MariaDB



## installation

* download, unzip, crete virtual-host, restart web-server
* composer based, setup, run
* docker based



## 



## pre-Check

(1)   
There are several ```composer*.json``` versions;    
the  ```~./composer.json``` is the only one you actually need;   
all others found under ```~./docker/config/composer-*,json``` are for testing/
case-study puproses; so make sure that ```~./composer.json``` is updated with
all required packages
 
(2)   
When deploying on PRODUCTION make sure that all development routes are deleted
and debuging messages are disabled.

(3)    
Anom pre-sets-up two writable folders:
* ```~/storage``` (pre-public directory) ideal for file-sessioning, file-caching;
also ideal for file-uploading when serve permition is needed;
* ```~/public/files``` (post-public folder) which is ideal for public access content
Make sure to keep the one that suits your needs (or both if needed);



## Build

    docker build -t x-anom .

Force build without using cache:

    docker build --no-cache -t x-anom .




## Run

    docker-compose up

Force rebuild; then run:

    docker-compose up --build




## Remove builded containers

    docker-compose down




## While developing...

By default autoloading is handled by Composer (this is highly recommended).
While developing your application (or the framework itself) you will need to
update the autoloading of your new classes. To do so, attach a shell, change
to ```/var/www``` directory and run ```composer dump-autoload```

    cd /var/www

    composer dump-autoload

If Composer is not an option and you use the framework's autoload implementation
(enabling ```define('AUTOLOADER' , '../core/helpers/autoload.php');```),
do not forger to update the (new) paths to your new classes in the ```CLASSPATHS```
array . Both ```AUTOLOADER``` and ```CLASSPATHS``` definitions can be found
into ```core/confing/anom_settings.php``` file.




## XDebug

anom comes with most configuration of XDebug ready; all you need is

1. on Doockerfile: uncoomment the commands under XDebug section

2. on docker-compose.yml: uncomment the services.web.extra_hosts section

3. you may need configure your ide to listen onto XDebuger host port

example: 
for vscode you need to add a ~./.vscode/launch.json file like this:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Listen for Xdebug",
                "type": "php",
                "request": "launch",
                "port": 9003,
                "pathMappings": {
                    "/var/www/public": "${workspaceRoot}/public"
                }
            }
        ]
    }




## Customization

The project includes several almost-ready-to-use technologies;
You can enable / customize / disable / configure all these with a few edits.

Each time you change the configuration of your environment, do not forget to set the
related parameters on the main configuration file (```/core/config/anom_settings.php)```
and/or define environmental variables or credentials to the ```/core/auth/.env``` file.

NOTE: #1
We assume that you use composer; if not, then whatever composer does you have to
make it manually (copy dependency files and setup the autoloader's paths).

NOTE: #2
There is no need to use both Redis and Memcached, thus I have not test if these
two caching technologies will work together using the proposed comfiguration.



#### Redis

To enable Redis...

Onto docker-compose.yml:

1. Uncomment the lines of 'redis' section; Your Redis-server host name will be the one that is specified in the container_name field (default: redis)

2. Uncomment the networks subsections; web-server and Redis-server will communicate through a bridge network

3. With composer:

Include predis/redis into your project's requirements using ```/docker/config/composer-redis.json```
as your composer.json file -or- install it via:

    composer require predis/predis



#### Memcached

To host the Memcached service:

1. Onto docker-compose.yml: uncomment the lines of 'memcached' section; Memcached-server host name will be the one that is specified in the container_name field (default: anomemcached)

2. Onto Dockerfile: uncomment the lines under subsection 'Install Memcached'


* TODO:
[set web ports and other options witn an .env file](https://stackoverflow.com/questions/52664673/how-to-get-port-of-docker-compose-from-env-file)


* TODO: Maria database


* TODO: Adminer
(https://stackoverflow.com/questions/33631085/how-to-use-adminer-with-composer-autoload-php)


* TODO: phpMyAdmin


* Apache


* Opcache and JIT


TODO:

## Staging

#### Build

#### Deploy


## Production

### Build

### Deploy

! Run the above commands ONLY when you need to manually deploy the app to Cloud Run, otherwise everything is automated using Cloud Builds




## Notes

* '~./' refers to the root of the project

* Furhter documentation about the framework can be found in ~./core/README.md