Skip to content

Commit d4c34cf

Browse files
committed
add DDEv tooling, improve mysql check, improve php conf check
1 parent 7e49dbc commit d4c34cf

File tree

4 files changed

+309
-16
lines changed

4 files changed

+309
-16
lines changed

.ddev/config.yaml

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
name: phpwpinfo
2+
type: php
3+
docroot: ""
4+
php_version: "8.2"
5+
webserver_type: nginx-fpm
6+
xdebug_enabled: false
7+
additional_hostnames: []
8+
additional_fqdns: []
9+
database:
10+
type: mariadb
11+
version: "10.11"
12+
use_dns_when_possible: true
13+
composer_version: "2"
14+
web_environment: []
15+
corepack_enable: false
16+
17+
# Key features of DDEV's config.yaml:
18+
19+
# name: <projectname> # Name of the project, automatically provides
20+
# http://projectname.ddev.site and https://projectname.ddev.site
21+
22+
# type: <projecttype> # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
23+
# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
24+
# information on the different project types
25+
# "drupal" covers recent Drupal 8+
26+
27+
# docroot: <relative_path> # Relative path to the directory containing index.php.
28+
29+
# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
30+
31+
# You can explicitly specify the webimage but this
32+
# is not recommended, as the images are often closely tied to DDEV's' behavior,
33+
# so this can break upgrades.
34+
35+
# webimage: <docker_image> # nginx/php docker image.
36+
37+
# database:
38+
# type: <dbtype> # mysql, mariadb, postgres
39+
# version: <version> # database version, like "10.11" or "8.0"
40+
# MariaDB versions can be 5.5-10.8, 10.11, and 11.4.
41+
# MySQL versions can be 5.5-8.0.
42+
# PostgreSQL versions can be 9-16.
43+
44+
# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
45+
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
46+
47+
# xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart"
48+
# Note that for most people the commands
49+
# "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better,
50+
# as leaving Xdebug enabled all the time is a big performance hit.
51+
52+
# xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart"
53+
# Note that for most people the commands
54+
# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better,
55+
# as leaving Xhprof enabled all the time is a big performance hit.
56+
57+
# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn
58+
59+
# timezone: Europe/Berlin
60+
# This is the timezone used in the containers and by PHP;
61+
# it can be set to any valid timezone,
62+
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
63+
# For example Europe/Dublin or MST7MDT
64+
65+
# composer_root: <relative_path>
66+
# Relative path to the Composer root directory from the project root. This is
67+
# the directory which contains the composer.json and where all Composer related
68+
# commands are executed.
69+
70+
# composer_version: "2"
71+
# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1
72+
# to use the latest major version available at the time your container is built.
73+
# It is also possible to use each other Composer version channel. This includes:
74+
# - 2.2 (latest Composer LTS version)
75+
# - stable
76+
# - preview
77+
# - snapshot
78+
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
79+
# To reinstall Composer after the image was built, run "ddev debug refresh".
80+
81+
# nodejs_version: "20"
82+
# change from the default system Node.js version to any other version.
83+
# Numeric version numbers can be complete (i.e. 18.15.0) or
84+
# incomplete (18, 17.2, 16). 'lts' and 'latest' can be used as well along with
85+
# other named releases.
86+
# see https://www.npmjs.com/package/n#specifying-nodejs-versions
87+
# Note that you can continue using 'ddev nvm' or nvm inside the web container
88+
# to change the project's installed node version if you need to.
89+
90+
# corepack_enable: false
91+
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm
92+
93+
# additional_hostnames:
94+
# - somename
95+
# - someothername
96+
# would provide http and https URLs for "somename.ddev.site"
97+
# and "someothername.ddev.site".
98+
99+
# additional_fqdns:
100+
# - example.com
101+
# - sub1.example.com
102+
# would provide http and https URLs for "example.com" and "sub1.example.com"
103+
# Please take care with this because it can cause great confusion.
104+
105+
# upload_dirs: "custom/upload/dir"
106+
#
107+
# upload_dirs:
108+
# - custom/upload/dir
109+
# - ../private
110+
#
111+
# would set the destination paths for ddev import-files to <docroot>/custom/upload/dir
112+
# When Mutagen is enabled this path is bind-mounted so that all the files
113+
# in the upload_dirs don't have to be synced into Mutagen.
114+
115+
# disable_upload_dirs_warning: false
116+
# If true, turns off the normal warning that says
117+
# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set"
118+
119+
# ddev_version_constraint: ""
120+
# Example:
121+
# ddev_version_constraint: ">= 1.22.4"
122+
# This will enforce that the running ddev version is within this constraint.
123+
# See https://github.com/Masterminds/semver#checking-version-constraints for
124+
# supported constraint formats
125+
126+
# working_dir:
127+
# web: /var/www/html
128+
# db: /home
129+
# would set the default working directory for the web and db services.
130+
# These values specify the destination directory for ddev ssh and the
131+
# directory in which commands passed into ddev exec are run.
132+
133+
# omit_containers: [db, ddev-ssh-agent]
134+
# Currently only these containers are supported. Some containers can also be
135+
# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit
136+
# the "db" container, several standard features of DDEV that access the
137+
# database container will be unusable. In the global configuration it is also
138+
# possible to omit ddev-router, but not here.
139+
140+
# performance_mode: "global"
141+
# DDEV offers performance optimization strategies to improve the filesystem
142+
# performance depending on your host system. Should be configured globally.
143+
#
144+
# If set, will override the global config. Possible values are:
145+
# - "global": uses the value from the global config.
146+
# - "none": disables performance optimization for this project.
147+
# - "mutagen": enables Mutagen for this project.
148+
# - "nfs": enables NFS for this project.
149+
#
150+
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs
151+
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen
152+
153+
# fail_on_hook_fail: False
154+
# Decide whether 'ddev start' should be interrupted by a failing hook
155+
156+
# host_https_port: "59002"
157+
# The host port binding for https can be explicitly specified. It is
158+
# dynamic unless otherwise specified.
159+
# This is not used by most people, most people use the *router* instead
160+
# of the localhost port.
161+
162+
# host_webserver_port: "59001"
163+
# The host port binding for the ddev-webserver can be explicitly specified. It is
164+
# dynamic unless otherwise specified.
165+
# This is not used by most people, most people use the *router* instead
166+
# of the localhost port.
167+
168+
# host_db_port: "59002"
169+
# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic
170+
# unless explicitly specified.
171+
172+
# mailpit_http_port: "8025"
173+
# mailpit_https_port: "8026"
174+
# The Mailpit ports can be changed from the default 8025 and 8026
175+
176+
# host_mailpit_port: "8025"
177+
# The mailpit port is not normally bound on the host at all, instead being routed
178+
# through ddev-router, but it can be bound directly to localhost if specified here.
179+
180+
# webimage_extra_packages: [php7.4-tidy, php-bcmath]
181+
# Extra Debian packages that are needed in the webimage can be added here
182+
183+
# dbimage_extra_packages: [telnet,netcat]
184+
# Extra Debian packages that are needed in the dbimage can be added here
185+
186+
# use_dns_when_possible: true
187+
# If the host has internet access and the domain configured can
188+
# successfully be looked up, DNS will be used for hostname resolution
189+
# instead of editing /etc/hosts
190+
# Defaults to true
191+
192+
# project_tld: ddev.site
193+
# The top-level domain used for project URLs
194+
# The default "ddev.site" allows DNS lookup via a wildcard
195+
# If you prefer you can change this to "ddev.local" to preserve
196+
# pre-v1.9 behavior.
197+
198+
# ngrok_args: --basic-auth username:pass1234
199+
# Provide extra flags to the "ngrok http" command, see
200+
# https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h"
201+
202+
# disable_settings_management: false
203+
# If true, DDEV will not create CMS-specific settings files like
204+
# Drupal's settings.php/settings.ddev.php or TYPO3's additional.php
205+
# In this case the user must provide all such settings.
206+
207+
# You can inject environment variables into the web container with:
208+
# web_environment:
209+
# - SOMEENV=somevalue
210+
# - SOMEOTHERENV=someothervalue
211+
212+
# no_project_mount: false
213+
# (Experimental) If true, DDEV will not mount the project into the web container;
214+
# the user is responsible for mounting it manually or via a script.
215+
# This is to enable experimentation with alternate file mounting strategies.
216+
# For advanced users only!
217+
218+
# bind_all_interfaces: false
219+
# If true, host ports will be bound on all network interfaces,
220+
# not the localhost interface only. This means that ports
221+
# will be available on the local network if the host firewall
222+
# allows it.
223+
224+
# default_container_timeout: 120
225+
# The default time that DDEV waits for all containers to become ready can be increased from
226+
# the default 120. This helps in importing huge databases, for example.
227+
228+
#web_extra_exposed_ports:
229+
#- name: nodejs
230+
# container_port: 3000
231+
# http_port: 2999
232+
# https_port: 3000
233+
#- name: something
234+
# container_port: 4000
235+
# https_port: 4000
236+
# http_port: 3999
237+
# Allows a set of extra ports to be exposed via ddev-router
238+
# Fill in all three fields even if you don’t intend to use the https_port!
239+
# If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start.
240+
#
241+
# The port behavior on the ddev-webserver must be arranged separately, for example
242+
# using web_extra_daemons.
243+
# For example, with a web app on port 3000 inside the container, this config would
244+
# expose that web app on https://<project>.ddev.site:9999 and http://<project>.ddev.site:9998
245+
# web_extra_exposed_ports:
246+
# - name: myapp
247+
# container_port: 3000
248+
# http_port: 9998
249+
# https_port: 9999
250+
251+
#web_extra_daemons:
252+
#- name: "http-1"
253+
# command: "/var/www/html/node_modules/.bin/http-server -p 3000"
254+
# directory: /var/www/html
255+
#- name: "http-2"
256+
# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000"
257+
# directory: /var/www/html
258+
259+
# override_config: false
260+
# By default, config.*.yaml files are *merged* into the configuration
261+
# But this means that some things can't be overridden
262+
# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge
263+
# and you can't erase existing hooks or all environment variables.
264+
# However, with "override_config: true" in a particular config.*.yaml file,
265+
# 'use_dns_when_possible: false' can override the existing values, and
266+
# hooks:
267+
# post-start: []
268+
# or
269+
# web_environment: []
270+
# or
271+
# additional_hostnames: []
272+
# can have their intended affect. 'override_config' affects only behavior of the
273+
# config.*.yaml file it exists in.
274+
275+
# Many DDEV commands can be extended to run tasks before or after the
276+
# DDEV command is executed, for example "post-start", "post-import-db",
277+
# "pre-composer", "post-composer"
278+
# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
279+
# information on the commands that can be extended and the tasks you can define
280+
# for them. Example:
281+
#hooks:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog ##
22

3+
## 1.6.0
4+
5+
- Better handle error management for mysql test connexion
6+
- Improve check with -1 value on PHP conf
7+
8+
## 1.5.0
9+
10+
- ADD: Favicon
11+
- ADD: WordPress Handbook link
12+
- UPDATE: Required version and modules
13+
- UPDATE: PHP requirement change from 5.6 to 7.4
14+
315
## 1.4.0
416
- Refactor readme
517
- Branding

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ If you really like what we do or want to thank us for our quick work, feel free
7777

7878
## License
7979

80-
phpwpinfo is licensed under the [GPLv3 or later](LICENSE.md).
80+
phpwpinfo is licensed under the [GPLv3 or later](LICENSE.md).

phpwpinfo.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
2020
1.5.0:
21-
[X] ADD: Favicon
22-
[X] ADD: WordPress Handbook link
23-
[X] UPDATE: Required version and modules
21+
2422
2523
TODO:
2624
[ ] Delete deprecated
@@ -49,7 +47,7 @@ function phpwpinfo() {
4947

5048
class PHP_WP_Info {
5149

52-
private $debug_mode = true;
50+
private bool $debug_mode = true;
5351
private $php_version = '≥7.4';
5452
private $mysql_version = '8.0'; // TODO: Min MariaDB version ?
5553
private $curl_version = '7.38';
@@ -401,10 +399,10 @@ public function test_php_config() {
401399
}
402400

403401
$value = $this->return_bytes( ini_get( 'memory_limit' ) );
404-
if ( (int) $value < $this->return_bytes( '64M' ) ) {
402+
if ( $value !== '-1' && (int) $value < $this->return_bytes( '64M' ) ) {
405403
$this->html_table_row( 'memory_limit', '64 MB', '256 MB', $this->_format_bytes( $value ), 'error' );
406404
} else {
407-
$status = ( (int) $value >= $this->return_bytes( '256M' ) ) ? 'success' : 'warning';
405+
$status = ( (int) $value >= $this->return_bytes( '256M' ) || $value === '-1' ) ? 'success' : 'warning';
408406
$this->html_table_row( 'memory_limit', '64 MB', '256 MB', $this->_format_bytes( $value ), $status );
409407
}
410408

@@ -417,18 +415,18 @@ public function test_php_config() {
417415
}
418416

419417
$value = ini_get( 'max_execution_time' );
420-
if ( (int) $value < 60 ) {
418+
if ( $value !== '-1' && (int) $value < 60 ) {
421419
$this->html_table_row( 'max_execution_time', '-', '300', $value, 'error' );
422420
} else {
423-
$status = ( (int) $value >= 300 ) ? 'success' : 'warning';
421+
$status = ( (int) $value >= 300 || $value === '-1' ) ? 'success' : 'warning';
424422
$this->html_table_row( 'max_execution_time', '-', '300', $value, $status );
425423
}
426424

427425
$value = ini_get( 'max_input_time' );
428-
if ( (int) $value < 60 ) {
426+
if ( $value !== '-1' && (int) $value < 60 ) {
429427
$this->html_table_row( 'max_input_time', '-', '300', $value, 'error' );
430428
} else {
431-
$status = ( (int) $value >= 300 ) ? 'success' : 'warning';
429+
$status = ( (int) $value >= 300 || $value === '-1' ) ? 'success' : 'warning';
432430
$this->html_table_row( 'max_input_time', '-', '300', $value, $status );
433431
}
434432

@@ -1105,7 +1103,7 @@ private function _get_current_webserver() {
11051103
/**
11061104
* Method for get apaches modules with Apache modules or CGI with .HTACCESS
11071105
*
1108-
* @return string [description]
1106+
* @return array [description]
11091107
*/
11101108
private function _get_apache_modules() {
11111109
$apache_modules = ( is_callable( 'apache_get_modules' ) ? apache_get_modules() : false );
@@ -1340,10 +1338,12 @@ private function _check_request_database() {
13401338

13411339
// Check credentials-db
13421340
if ( ! empty( $this->db_infos ) && is_array( $this->db_infos ) && is_callable( 'mysqli_connect' ) ) {
1343-
$this->db_link = @mysqli_connect( $this->db_infos['host'],
1344-
$this->db_infos['user'],
1345-
$this->db_infos['password'] );
1346-
if ( $this->db_link === false ) {
1341+
try {
1342+
$this->db_link = mysqli_connect( $this->db_infos['host'],
1343+
$this->db_infos['user'],
1344+
$this->db_infos['password'] );
1345+
} catch ( Exception $e ) {
1346+
$error = $e->getMessage();
13471347
unset( $_SESSION['credentials-db'] );
13481348
$this->db_infos = false;
13491349
}

0 commit comments

Comments
 (0)