{"id":21336803,"url":"https://github.com/dan-da/strictmode-php","last_synced_at":"2025-03-16T02:12:12.026Z","repository":{"id":56961623,"uuid":"102609948","full_name":"dan-da/strictmode-php","owner":"dan-da","description":"A tiny php include to make php code more strict and catch problems sooner.","archived":false,"fork":false,"pushed_at":"2023-11-05T17:51:24.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T19:12:09.741Z","etag":null,"topics":["php","php-strict","strictmode"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dan-da.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-06T13:10:51.000Z","updated_at":"2023-11-05T17:49:38.000Z","dependencies_parsed_at":"2022-08-21T10:20:36.574Z","dependency_job_id":null,"html_url":"https://github.com/dan-da/strictmode-php","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fstrictmode-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fstrictmode-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fstrictmode-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fstrictmode-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-da","download_url":"https://codeload.github.com/dan-da/strictmode-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814893,"owners_count":20352038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-strict","strictmode"],"created_at":"2024-11-21T23:55:20.079Z","updated_at":"2025-03-16T02:12:12.008Z","avatar_url":"https://github.com/dan-da.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strictmode-php\n\nA tiny php include to make php code more strict and catch problems sooner.\n\nThis library catches all PHP notices, warnings, and errors and turns them\ninto PHP exceptions.\n\nIt also catches all uncaught exceptions and prints a stack trace.  It can\nalso send an email alert for uncaught exceptions.\n\nThe net result is that minor problems are caught early in development and it\nforces the developer to write much cleaner code.\n\nThe email alerts are useful for production environments, to notify site\noperators of any problems.\n\nstrictmode.php is a single file that can be included with require_once or can be\nincluded via autoload when using composer.\n\n\n# Let's see an example.\n\napp code:\n\nThis uses require_once(), see below for autoload example.\n\n```\n\u003c?php\nrequire_once( __DIR__ . '/../strictmode.php');\ndefine( 'strictmode\\ALERTS_MAILTO', 'yourmail@yourdomain.com' );\n...\n\necho HELLO;   // this will generate a PHP notice.\n```\n\noutput:\n\n```\nUncaught Exception. code: 8, message: Use of undefined constant HELLO - assumed 'HELLO'\n/home/danda/dev/strictmode-php/t.php : 7\n\nStack Trace:\n#0 /home/danda/dev/strictmode-php/t.php(7): strictmode\\_global_error_handler(8, 'Use of undefine...', '/home/danda/dev...', 7, Array)\n#1 {main}\n\nINFO: alert sent to yourmail@yourdomain.com\n\n\nNow exiting.  Please report this problem to the software author\n```\n\n\nFor comparison, here is normal php output without strictmode.php\n\n```\nPHP Notice:  Use of undefined constant HELLO - assumed 'HELLO' in /home/danda/dev/strictmode-php/t.php on line 7\nHELLO\n```\n\n# including via composer / autoload\n\n```\n\u003c?php\nrequire_once __DIR__  . '/../vendor/autoload.php';\ndefine( 'strictmode\\ALERTS_MAILTO', 'yourmail@yourdomain.com' );\n\\strictmode\\initializer::init();\n\n// your app code...\n```\n\n\n# Configuring email alerts\n\n## set alert address\n\n```\ndefine( 'strictmode\\ALERTS_MAILTO', 'yourmail@yourdomain.com' );\n```\n\n## disable warning if ALERTS_MAILTO not set\n\n```\ndefine( 'strictmode\\ALERTS_DISABLE', 1 );\n```\n\n\n# Installation and Running.\n\nInstall strictmode-php into your own project using a composer require in your\nproject's composer.json, eg:\n\n```\n    $ cd yourproject\n    $ composer require dan-da/strictmode-php\n```\n\nThen run composer install.\n\n\n# Todos\n\n* add more test cases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fstrictmode-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-da%2Fstrictmode-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fstrictmode-php/lists"}