PHPackages                             azmolla/blade-try-catch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. azmolla/blade-try-catch

ActiveLibrary[Templating &amp; Views](/categories/templating)

azmolla/blade-try-catch
=======================

Blade directives for try-catch-finally blocks in Laravel Blade templates

0.0.3(12mo ago)011MITPHPPHP ^7.1 || ^8.0

Since Jul 8Pushed 12mo agoCompare

[ Source](https://github.com/AbiruzzamanMolla/blade-try-catch)[ Packagist](https://packagist.org/packages/azmolla/blade-try-catch)[ Docs](https://github.com/AbiruzzamanMolla/blade-try-catch)[ RSS](/packages/azmolla-blade-try-catch/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (4)Used By (0)

Blade Try-Catch Directives for Laravel
======================================

[](#blade-try-catch-directives-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bf181a9fc13cac5cd01c5d206a5398ffeb267b074bac040ea7c73fb2fe9b824c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617a6d6f6c6c612f626c6164652d7472792d63617463682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/azmolla/blade-try-catch)[![License](https://camo.githubusercontent.com/900c0b9418adca58aa61facf9d6c8647c36bda057ea5782638ee32dc1ca4e5b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617a6d6f6c6c612f626c6164652d7472792d63617463682e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

---

Overview
--------

[](#overview)

This Laravel package adds native-like `@try`, `@catch`, `@finally`, and `@endtry` directives to Blade templates, allowing you to handle exceptions gracefully inside your views.

You no longer need to clutter your controllers for simple error handling in views — this package provides a clean, elegant syntax for try-catch-finally in Blade.

Compatible with **Laravel 5.8 through 12** and PHP 7.1+.

---

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require azmolla/blade-try-catch
```

The package auto-registers the service provider via Laravel's package discovery. No manual provider registration needed.

---

Usage
-----

[](#usage)

Use the directives in any Blade view:

```
@try
    {{-- Code that may throw an exception --}}
    {{ riskyFunction() }}
@catch(\Exception $e)
    {{-- Handle the exception --}}
    Error: {{ $e->getMessage() }}
@finally
    {{-- Code that always runs --}}
    Cleanup completed.
@endtry
```

---

Testing
-------

[](#testing)

This package uses [Pest](https://pestphp.com/) for testing.

To run tests locally:

```
composer test
```

Make sure to install development dependencies before running tests:

```
composer install --dev
```

---

Contributing
------------

[](#contributing)

Contributions, issues, and feature requests are welcome!

1. Fork the repo
2. Create your feature branch (`git checkout -b feature/my-feature`)
3. Commit your changes (`git commit -m 'Add new feature'`)
4. Push to the branch (`git push origin feature/my-feature`)
5. Open a pull request

Please ensure your code passes existing tests and write new tests if applicable.

---

Links &amp; Credits
-------------------

[](#links--credits)

- Author: Abiruzzaman Molla ([GitHub](https://github.com/abiruzzamanmolla), [Packagist](https://packagist.org/packages/azmolla))
- License: MIT

---

License
-------

[](#license)

MIT © 2025 Abiruzzaman Molla

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance50

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

361d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20683047?v=4)[Abiruzzaman Molla](/maintainers/AbiruzzamanMolla)[@AbiruzzamanMolla](https://github.com/AbiruzzamanMolla)

---

Top Contributors

[![AbiruzzamanMolla](https://avatars.githubusercontent.com/u/20683047?v=4)](https://github.com/AbiruzzamanMolla "AbiruzzamanMolla (5 commits)")

---

Tags

bladeblade-templatecustom-directiveslaravellaravelbladeerror handlingtry-catch

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/azmolla-blade-try-catch/health.svg)

```
[![Health](https://phpackages.com/badges/azmolla-blade-try-catch/health.svg)](https://phpackages.com/packages/azmolla-blade-try-catch)
```

###  Alternatives

[blade-ui-kit/blade-icons

A package to easily make use of icons in your Laravel Blade views.

2.5k42.5M404](/packages/blade-ui-kit-blade-icons)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k570.6k23](/packages/robsontenorio-mary)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18421.4k11](/packages/technikermathe-blade-lucide-icons)[hasinhayder/tyro-login

Tyro Login - Beautiful, customizable authentication views for Laravel 12 &amp; 13

2464.9k6](/packages/hasinhayder-tyro-login)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
