1
1
PHP Debug Mode Enabler
2
2
======================
3
- > not only for Tracy debugger
4
3
5
- Safe and clean way to manage Debug Mode in your app by specific environment and/or manually in app.
6
- Package provide secure way to temporary switch Debug Mode of your App at any environment.
4
+ Safe and clean way to manage Debug Mode in your app by specific environment and/or manually in App.
5
+ Package automatically detects development environments and provide secure way to temporary switch Debug Mode of your App
6
+ at any environment.
7
7
8
8
## Features
9
9
Package allows your app to switch to Debug Mode:
10
10
- automatically on localhost's environment by IP,
11
11
- semi-automatically on any environment where you set ` APP_DEBUG ` environment variable (useful for Docker dev-stack),
12
- - allows you to switch (force turn-on or turn-off) Debug Mode manually.
12
+ - semi-automatically disable Debug mode on any environment where you set ` app-debug-mode ` cookie variable (useful for
13
+ tests and similar cases),
14
+ - manually enable/disable (force turn-on or turn-off) Debug Mode.
13
15
14
- > NOTE: Package is NOT provide any Debug tools directly – it only gives the app whether to switch to debug mode.
16
+ ** NOTE:** Package is NOT provide any Debug tools directly – it only gives the app whether to switch to debug mode.
17
+
18
+ Package is optimized for invoking in very early lifecycle phase of your App and
19
+
20
+ ## Requirements
21
+ Package is requires:
22
+
23
+ - PHP version at least 7.3
24
+ - Temporary directory with writable access
15
25
16
26
## Installation
17
27
``` shell
18
28
composer require redbitcz/debug-mode-enabler
19
29
```
20
30
21
- ## Requirements
22
- Package is requires PHP version at least 7.3 and temporary directory with writable access.
23
-
24
31
## Using
25
32
Anywhere in your app you can determine if app is running in Debug mode by simple code:
26
33
``` php
27
- $detector = new \Redbitcz\DebugMode\Detector($tempDir);
28
- $debugMode = $detector->isDebugMode(); // boolean
34
+ $debugMode = \Redbitcz\DebugMode\Detector::detect($tempDir); //bool
29
35
```
30
- where ` $tempDir ` is required absolute path to temporary directory.
36
+ where ` $tempDir ` is required path to temporary directory.
31
37
32
38
It returns ` $debugMode ` = ` true ` when is detected Debug environment or manually switched.
33
39
34
40
### Using with Nette
35
- In ` \App\Bootstrap ` class use package like this example:
41
+ In Boostrap use package like this example:
36
42
``` php
37
43
$tempDir = __DIR__ . '/../temp';
38
44
$debugModeDetector = new \Redbitcz\DebugMode\Detector($tempDir);
@@ -58,10 +64,6 @@ environment:
58
64
` ` `
59
65
60
66
## Manually switch
61
- <p align="center">
62
- <img width="368" height="280" src="https://user-images.githubusercontent.com/1657322/78752208-f2354a00-7973-11ea-83ea-b2719e326dc8.png">
63
- </p>
64
-
65
67
**WARNING – DANGER ZONE:** Following feature allows to force Debug Mode on any environment, production including.
66
68
Please use it with great caution only! Wrong use might cause to critical security issue! Before using Enabler's feature be
67
69
aware your app is resistant to XSS, CSRF and similar attacks!
@@ -86,8 +88,8 @@ services:
86
88
- Redbitcz\DebugMode\Enabler(%tempDir%)
87
89
` ` `
88
90
89
- At most cases this example is creates second instance of ` DebugModeEnabler ` class because first one is already created
90
- internally with `DebugModeDetector ` instance in `Bootstrap`.
91
+ At most cases this example is creates second instance of ` Enabler ` class because first one is already created
92
+ internally with `Detector ` instance in `Bootstrap`.
91
93
92
94
To re-use already exists instance you can inject it to DI Container :
93
95
` ` ` php
@@ -108,24 +110,4 @@ services:
108
110
` ` `
109
111
110
112
# # License
111
- The MIT License (MIT)
112
-
113
- Copyright (c) 2020 Redbit s.r.o., Jakub Bouček
114
-
115
- Permission is hereby granted, free of charge, to any person obtaining a copy
116
- of this software and associated documentation files (the "Software"), to deal
117
- in the Software without restriction, including without limitation the rights
118
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
119
- copies of the Software, and to permit persons to whom the Software is
120
- furnished to do so, subject to the following conditions :
121
-
122
- The above copyright notice and this permission notice shall be included in all
123
- copies or substantial portions of the Software.
124
-
125
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
126
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
127
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
128
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
129
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
130
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
131
- SOFTWARE.
113
+ The MIT License (MIT). Please see [License File](LICENSE) for more information.
0 commit comments