Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Özel Hata Sayfaları İçin Whoops Kullanıldı
Browse files Browse the repository at this point in the history
  • Loading branch information
yuceltoluyag committed Apr 15, 2019
1 parent 3740d0f commit 0ab2cd4
Show file tree
Hide file tree
Showing 49 changed files with 4,923 additions and 12 deletions.
44 changes: 44 additions & 0 deletions app/classes/ErrorHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php


namespace App\Classes;


class ErrorHandler
{
public function handleErrors($error_number,$error_message,$error_file,$error_line)
{
$error ="[{$error_number}] Bir Hata Oluştu
{$error_file} dosyasında $error_line : $error_message";

$environment = getenv('APP_ENV');
if ($environment === 'local') {
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
} else {
$data = [
'to' => getenv('ADMIN_EMAIL'),
'subject' => 'Sistem Hatası',
'view'=>'errors',
'name'=> 'Admin',
'body'=> 'Test Ediyoruz Email Şablonunu'

];

ErrorHandler::emailAdmin($data)->outputFriendlyError();
}
}
public function outputFriendlyError()
{
ob_end_clean();
view('errors/generic');
exit();
}
public static function emailAdmin($data)
{
$mail = new Mail;
$mail->send($data);
return new static;
}
}
15 changes: 6 additions & 9 deletions app/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ class IndexController extends BaseController
public function show()
{
echo 'Burası Ana Baba Günü';
$mail = new Mail();
$data = [
'to' => 'test@example.com',
'subject' => 'Hoşgeldiniz Biladerim',
'view'=>'welcome',
'body'=> 'Test Ediyoruz Email Şablonunu'

];

/**
* Özel Hata Sayfası İçin Mail Fonksiyonu Eksik Yazıldı
* Test Edildi : Whoops
*/
/* $mail = new Mail();
if ($mail->send($data)) {
echo 'email Başarıyla Gönderildi';
} else {
echo 'email Gönderilemedi';
}
}*/
}
}
7 changes: 6 additions & 1 deletion bootstrap/init.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php

// Oturum Başlamadıysa Başlatıyoruz
if (!isset($_SESSION)) session_start();
// Environment Ayarları
require_once __DIR__ . '/../app/config/_env.php';
//VeriTabanı Sınıfı Yükleme
new \App\Classes\Database();
// Özel Hata Sayfaları : Whoops
set_error_handler([new \App\Classes\ErrorHandler(),'handleErrors']);
// Routing & Url Sınıfı
require_once __DIR__ . '/../app/routing/routes.php';
new \App\RouteDispatcher($router);
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"illuminate/database": "^5.8",
"phpmailer/phpmailer": "^6.0"
},
"autoload": {
"require-dev": {
"filp/whoops": "^2.3"
},
"autoload": {
"psr-4": {
"App\\" : "app"
},
Expand Down
63 changes: 62 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions resources/views/emails/errors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="width: 500px; padding: 15px; margin: 0 auto; background-color: darkred;color: #ffffff;">
<img width="150px" height="75px" src="https://yt3.ggpht.com/a-/AAuE7mAzi4VaiH3-qZFpvB93AcQQVuq7Rq90ohCb9Q=s900-mo-c-c0xffffffff-rj-k-no" alt="BabaFinger">
<?php echo "HATA : {$data};"?>
</div>

</body>
</html>
3 changes: 3 additions & 0 deletions resources/views/errors/generic.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div style="padding: 15px; width: 80%; margin: 0 auto; border: 1px solid darkgray; border-radius: 5px;">
<h1>Bir Hata Oluştu, Daha Sonra Tekrar Denemeyin : )</h1>
</div>
18 changes: 18 additions & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,22 @@
'Symfony\\Contracts\\Translation\\TranslatorTrait' => $vendorDir . '/symfony/contracts/Translation/TranslatorTrait.php',
'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php',
'Symfony\\Polyfill\\Mbstring\\Mbstring' => $vendorDir . '/symfony/polyfill-mbstring/Mbstring.php',
'Whoops\\Exception\\ErrorException' => $vendorDir . '/filp/whoops/src/Whoops/Exception/ErrorException.php',
'Whoops\\Exception\\Formatter' => $vendorDir . '/filp/whoops/src/Whoops/Exception/Formatter.php',
'Whoops\\Exception\\Frame' => $vendorDir . '/filp/whoops/src/Whoops/Exception/Frame.php',
'Whoops\\Exception\\FrameCollection' => $vendorDir . '/filp/whoops/src/Whoops/Exception/FrameCollection.php',
'Whoops\\Exception\\Inspector' => $vendorDir . '/filp/whoops/src/Whoops/Exception/Inspector.php',
'Whoops\\Handler\\CallbackHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/CallbackHandler.php',
'Whoops\\Handler\\Handler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/Handler.php',
'Whoops\\Handler\\HandlerInterface' => $vendorDir . '/filp/whoops/src/Whoops/Handler/HandlerInterface.php',
'Whoops\\Handler\\JsonResponseHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php',
'Whoops\\Handler\\PlainTextHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/PlainTextHandler.php',
'Whoops\\Handler\\PrettyPageHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php',
'Whoops\\Handler\\XmlResponseHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php',
'Whoops\\Run' => $vendorDir . '/filp/whoops/src/Whoops/Run.php',
'Whoops\\RunInterface' => $vendorDir . '/filp/whoops/src/Whoops/RunInterface.php',
'Whoops\\Util\\HtmlDumperOutput' => $vendorDir . '/filp/whoops/src/Whoops/Util/HtmlDumperOutput.php',
'Whoops\\Util\\Misc' => $vendorDir . '/filp/whoops/src/Whoops/Util/Misc.php',
'Whoops\\Util\\SystemFacade' => $vendorDir . '/filp/whoops/src/Whoops/Util/SystemFacade.php',
'Whoops\\Util\\TemplateHelper' => $vendorDir . '/filp/whoops/src/Whoops/Util/TemplateHelper.php',
);
1 change: 1 addition & 0 deletions vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$baseDir = dirname($vendorDir);

return array(
'Whoops\\' => array($vendorDir . '/filp/whoops/src/Whoops'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Contracts\\' => array($vendorDir . '/symfony/contracts'),
Expand Down
26 changes: 26 additions & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class ComposerStaticInit331a0e945046aa52ebf60e308e832d29
);

public static $prefixLengthsPsr4 = array (
'W' =>
array (
'Whoops\\' => 7,
),
'S' =>
array (
'Symfony\\Polyfill\\Mbstring\\' => 26,
Expand Down Expand Up @@ -57,6 +61,10 @@ class ComposerStaticInit331a0e945046aa52ebf60e308e832d29
);

public static $prefixDirsPsr4 = array (
'Whoops\\' =>
array (
0 => __DIR__ . '/..' . '/filp/whoops/src/Whoops',
),
'Symfony\\Polyfill\\Mbstring\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
Expand Down Expand Up @@ -695,6 +703,24 @@ class ComposerStaticInit331a0e945046aa52ebf60e308e832d29
'Symfony\\Contracts\\Translation\\TranslatorTrait' => __DIR__ . '/..' . '/symfony/contracts/Translation/TranslatorTrait.php',
'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php',
'Symfony\\Polyfill\\Mbstring\\Mbstring' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/Mbstring.php',
'Whoops\\Exception\\ErrorException' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/ErrorException.php',
'Whoops\\Exception\\Formatter' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/Formatter.php',
'Whoops\\Exception\\Frame' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/Frame.php',
'Whoops\\Exception\\FrameCollection' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/FrameCollection.php',
'Whoops\\Exception\\Inspector' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/Inspector.php',
'Whoops\\Handler\\CallbackHandler' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/CallbackHandler.php',
'Whoops\\Handler\\Handler' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/Handler.php',
'Whoops\\Handler\\HandlerInterface' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/HandlerInterface.php',
'Whoops\\Handler\\JsonResponseHandler' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php',
'Whoops\\Handler\\PlainTextHandler' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/PlainTextHandler.php',
'Whoops\\Handler\\PrettyPageHandler' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php',
'Whoops\\Handler\\XmlResponseHandler' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php',
'Whoops\\Run' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Run.php',
'Whoops\\RunInterface' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/RunInterface.php',
'Whoops\\Util\\HtmlDumperOutput' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Util/HtmlDumperOutput.php',
'Whoops\\Util\\Misc' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Util/Misc.php',
'Whoops\\Util\\SystemFacade' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Util/SystemFacade.php',
'Whoops\\Util\\TemplateHelper' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Util/TemplateHelper.php',
);

public static function getInitializer(ClassLoader $loader)
Expand Down
63 changes: 63 additions & 0 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,69 @@
"string"
]
},
{
"name": "filp/whoops",
"version": "2.3.1",
"version_normalized": "2.3.1.0",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
"reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/bc0fd11bc455cc20ee4b5edabc63ebbf859324c7",
"reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7",
"shasum": ""
},
"require": {
"php": "^5.5.9 || ^7.0",
"psr/log": "^1.0.1"
},
"require-dev": {
"mockery/mockery": "^0.9 || ^1.0",
"phpunit/phpunit": "^4.8.35 || ^5.7",
"symfony/var-dumper": "^2.6 || ^3.0 || ^4.0"
},
"suggest": {
"symfony/var-dumper": "Pretty print complex values better with var-dumper available",
"whoops/soap": "Formats errors as SOAP responses"
},
"time": "2018-10-23T09:00:00+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Whoops\\": "src/Whoops/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Filipe Dobreira",
"homepage": "https://github.com/filp",
"role": "Developer"
}
],
"description": "php error handling for cool kids",
"homepage": "https://filp.github.io/whoops/",
"keywords": [
"error",
"exception",
"handling",
"library",
"throwable",
"whoops"
]
},
{
"name": "illuminate/container",
"version": "v5.8.11",
Expand Down
25 changes: 25 additions & 0 deletions vendor/filp/whoops/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 2.3.1

* Prevent exception in Whoops when caught exception frame is not related to real file

# 2.3.0

* Show previous exception messages.

# 2.2.0

* Support PHP 7.2

# 2.1.0

* Add a `SystemFacade` to allow clients to override Whoops behavior.
* Show frame arguments in `PrettyPageHandler`.
* Highlight the line with the error.
* Add icons to search on Google and Stack Overflow.

# 2.0.0

Backwards compatibility breaking changes:

* `Run` class is now `final`. If you inherited from `Run`, please now instead use a custom `SystemFacade` injected into the `Run` constructor, or contribute your changes to our core.
* PHP < 5.5 support dropped.
19 changes: 19 additions & 0 deletions vendor/filp/whoops/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit 0ab2cd4

Please sign in to comment.