GithubHelp home page GithubHelp logo

cakephp-whoops's Introduction

Whoops for CakePHP

CI Total Downloads Latest Stable Version Minimum PHP Version License

Seamlessly integrate Whoops into CakePHP applications.

Demo-Video: Linux Mint + Firefox

This branch is for use with CakePHP 5.0+. For details see version map.

Install

Using Composer:

composer require dereuromark/cakephp-whoops

As this package only offers a Whoops handler for CakePHP, there is no need to enable it (no ->addPlugin() call). You only need to configure the renderer classes inside your config/app.php or config/app_local.php:

'Error' => [
	'exceptionRenderer' => \CakephpWhoops\Error\WhoopsExceptionRenderer::class,
	'errorRenderer' => \CakephpWhoops\Error\WhoopsErrorRenderer::class
],

When using new Application.php and Middleware approach, you also need to adjust that:

// Replace ErrorHandlerMiddleware with
 ->add(new \CakephpWhoops\Error\Middleware\WhoopsHandlerMiddleware(Configure::read('Error')))

Debug Mode

An important note: This plugin is installed as require dependency, but even so it is more used as require-dev one. If the debug mode is off, it will completely ignore the Whoops handler, as without debug mode there is no exception to render. It will then display the public error message and only log internally.

So make sure you enable debug (locally) for checking out this package. For each error and exception you should then see the improved whoops handler output on your screen.

Editor

Opening the file in the editor via click in the browser is supported for most major IDEs. It uses phpstorm:// URLs which can open the file through a command line call and directly jump to the right line.

Set your config as

	'Whoops' => [
		'editor' => true,
	],

To enable it.

If you are using a VM, e.g. CakeBox, you will also need the path mapping:

		'userBasePath' => 'C:\wamp\www\cakebox\Apps\my-app.local',
		'serverBasePath' => '/home/vagrant/Apps/my-app.local',

If you would like to override the default URL handler (phpstorm://) you could do so by setting the ideLinkPattern option to a custom URL handler:

  • PhpStorm: phpstorm://open?file=%s&line=%s
  • Visual Studio Code: vscode://file/%s:%s

See the Wiki for more details on different OS and Browsers.

Strictness

As a bonus the error handler is a bit more strict here for development. It will not just ignore notices and other errors, but display them the same way in order to fix them with the same ease and speed as exceptions.

Usually, when a variable is not found, all following code can also not yield any useful results, as the example below shows. Better to code cleaner in the first place and to avoid any warning or notice to be thrown in the first place.

Before:

Screenshot

After:

Screenshot

cakephp-whoops's People

Contributors

admad avatar challgren avatar davidyell avatar dereuromark avatar jadb avatar josbeir avatar lordsimal avatar softius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cakephp-whoops's Issues

Requests for json which generate an error are returned as HTML

What is happening?

When my internal web service calls and endpoint for an item which doesn't exist, instead of a JSON 404 response. I get a full Whoops HTML page.

eg, http://cqt.dave/api/audits/fetch/5

What you expected to happen

I would think Whoops should be bypassed, and a JSON error response should be generated instead.

Wiki Setup Instructions

Thank you for forking the project.

In the Wiki I suggest you add:

Setup for Arch Linux or Antergos

Install the AUR package phpstorm-urlhandler.

Also it might be good to add that for browsers other than Firefox, installing the .desktop file from sanduhrs/phpstorm-url-handler is the way to go to make the URL work on a modern GNU/Linux desktop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.