- Download Docbook 5.0 (make sure it has xsd directory / files)
- https://docbook.org/xml/5.0.1/docbook-5.0.1.zip
- Place contents in project directory
- Settings > Languages > Schemas & DTDs
- Configure custom schema
- URL: http://docbook.org/ns/docbook
- File: xsd/docbook.xsd you just downloaded
- Configure custom schema
-
Set up a "read-only" user in addition to your administrative user and use that by default unless you actually need to make changes on production servers.
-
Disable autocommit, or use explicit transactions so you can rollback mistakes. (Beware of implicit commits)
-
To avoid
UPDATE
withoutWHERE
you can enablesql_safe_updates
. Some clients have similar options. -
Get into the habit of running a SELECT query before running an UPDATE to check which (and how many) records you've selected.
-
Use color schemes to differentiate between hosts. Many terminal clients and SQL clients have the ability to set / change the color scheme.
This is a guide to setting up Jenkins for PHP projects. The Jenkins plugins required are linked in each section below.
Be sure to check the pipeline step reference link on the plugin pages linked below for full documentation and options for Jenkinsfile.
This guide uses Jenkinsfile based pipelines and assumes you already have a basic Jenkinsfile.
This guide assumes that you already have each of the tools mentioned configured for use outside of Jenkins. Only the necessary configuration options for working with Jenkins are mentioned.
<?php | |
ini_set('memory_limit', '2M'); | |
function shutdownHandler() | |
{ | |
print "Shutdown handler triggered\n"; | |
print "Memory limit: ". ini_get('memory_limit') ."\n"; | |
// If the next line is commented, a second OOM will be triggered | |
ini_set('memory_limit', '-1'); | |
print "Memory limit: ". ini_get('memory_limit') ."\n"; |
<?php | |
class DateTimeFactory | |
{ | |
public static function createImmutableFromFormat(string $format, string $time, \DateTimeZone $timezone = null) : \DateTimeImmutable | |
{ | |
$dt = \DateTimeImmutable::createFromFormat($format, $time, $timezone); | |
// DateTime errors/warnings can occur even if the object was successfully created (eg. invalid date) |
.IssueLabel { | |
border-radius: 3px !important; | |
padding: 0 3px !important; | |
} | |
.UnderlineNav { | |
justify-content: center; | |
} | |
.UnderlineNav-item { |
public function fatalMemory() : void | |
{ | |
$a = ''; | |
while (true) { | |
$a .= str_repeat("Hello", 1024 * 1024); | |
} | |
} | |
public function timeout() : void |
- Decimal type / Decimal math by default (as opposed to floats)
- Related internals threads:
- Null-safe cast operations
- Generics
- "Interface" for callables / closures
<?php | |
declare(strict_types=1); | |
// Prometheus metrics exporter for PHP-FPM | |
header("Content-Type: text/plain; version=0.0.4"); | |
$stats = null; | |
$protocol = ((!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off") ? "https" : "http"); | |
$result = file_get_contents($protocol ."://" . $_SERVER["SERVER_NAME"] . "/php-fpm-status?json&full"); | |
if ($result !== false) { |
<?php | |
// https://3v4l.org/e79nG | |
$arr1 = [1, 2, 3]; | |
$arr2 = [2, 4, 1]; | |
$arr1 += $arr2; | |
var_dump($arr1); | |
$arr1 = ["foo", "bar", "baz"]; |