<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by M. K. T. M. Sameera on Medium]]></title>
        <description><![CDATA[Stories by M. K. T. M. Sameera on Medium]]></description>
        <link>https://medium.com/@mktmsameera?source=rss-814e8bc5c3ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*P_9-75l_6pTDgfqBqQ51eg.jpeg</url>
            <title>Stories by M. K. T. M. Sameera on Medium</title>
            <link>https://medium.com/@mktmsameera?source=rss-814e8bc5c3ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:03:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mktmsameera/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Laravel Coding Best Practices — 03 (Advanced & Deep Dive )]]></title>
            <link>https://mktmsameera.medium.com/laravel-coding-best-practices-03-advanced-deep-dive-2811c5a02b11?source=rss-814e8bc5c3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/2811c5a02b11</guid>
            <dc:creator><![CDATA[M. K. T. M. Sameera]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 15:20:58 GMT</pubDate>
            <atom:updated>2025-09-17T15:20:58.207Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel Coding Best Practices — 03 (Advanced &amp; Deep Dive )</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*fTzTuudRoc3D-JoxPi-Geg.png" /></figure><p>In <a href="https://medium.com/@mktmsameera/laravel-coding-best-practices-01-1e4f4aae8cda">Part 01</a> we discussed naming conventions, and in Part 02 we focused on <strong>clean controllers, requests, models, caching, API resources, testing, and code readability</strong>.</p><p>Now, we are going <strong>very deep</strong>. This part covers advanced practices that <strong>large, scalable Laravel applications</strong> rely on.</p><h3>1. Service Layer, Actions &amp; Domain Separation</h3><p>Controllers should orchestrate actions but <strong>never implement business logic</strong>.</p><p><strong>Action Classes / Service Layer:</strong></p><pre>class CreateOrderAction<br>{<br>    public function execute(array $data): Order<br>    {<br>        $order = Order::create($data);<br>        event(new OrderCreated($order));<br>        return $order;<br>    }<br>}</pre><p><strong>Benefits:</strong></p><ul><li>Single Responsibility Principle (SRP)</li><li>Reusable across CLI commands, controllers, and jobs</li><li>Easier to test</li></ul><p><strong>Tip:</strong> For very large apps, consider <strong>Domain-Driven Design (DDD)</strong> separation:</p><ul><li>Domain — business rules and entities</li><li>Application — orchestrates domain objects</li><li>Infrastructure — database, APIs, queues</li></ul><h3>2. Events &amp; Listeners — Fully Leverage</h3><p>Decoupling via <strong>events</strong> improves maintainability.</p><pre>event(new UserRegistered($user));</pre><p><strong>Queued listeners:</strong></p><pre>class SendWelcomeEmail implements ShouldQueue<br>{<br>    public function handle(UserRegistered $event)<br>    {<br>        Mail::to($event-&gt;user-&gt;email)-&gt;send(new WelcomeMail($event-&gt;user));<br>    }<br>}</pre><p><strong>Best Practices:</strong></p><ul><li>Fire events from services, not controllers</li><li>Group related listeners logically</li><li>Use Event::dispatch instead of event() in heavy apps for clarity</li></ul><h3>3. Jobs &amp; Queues</h3><p>Anything time-consuming should go into a <strong>job</strong>.</p><pre>dispatch(new GenerateMonthlyReport($user));</pre><p><strong>Advanced Queue Techniques:</strong></p><ul><li>Use multiple queue connections for heavy tasks vs normal tasks</li><li>Retry failed jobs with backoff strategies:</li></ul><pre>public $tries = 3;<br>public $backoff = [60, 120, 300]; // seconds</pre><ul><li><strong>Batch jobs</strong>: Run multiple jobs together and track completion</li></ul><pre>Bus::batch([<br>    new SendEmailJob($user1),<br>    new SendEmailJob($user2),<br>])-&gt;dispatch();</pre><h3>4. Caching &amp; Performance</h3><p>Advanced caching patterns:</p><p><strong>Query Caching:</strong></p><pre>$activeUsers = Cache::remember(&#39;active_users&#39;, 3600, fn() =&gt; User::active()-&gt;get());</pre><p><strong>Tag-based caching:</strong></p><pre>Cache::tags([&#39;users&#39;, &#39;orders&#39;])-&gt;flush();</pre><p><strong>Fragment caching in Blade:</strong></p><pre>@cache(&#39;sidebar_menu&#39;, 3600)<br>   {{-- render heavy menu --}}<br>@endcache</pre><p><strong>Database optimization:</strong></p><ul><li>Add <strong>indexes</strong> on frequently queried columns</li><li>Use EXPLAIN to debug slow queries</li><li>Prefer <strong>bulk updates/inserts</strong> to looping</li></ul><p><strong>Eloquent Optimization:</strong></p><ul><li>Use chunk or cursor for processing large datasets</li><li>Always eager-load relationships to avoid N+1 queries</li></ul><h3>5. Advanced Eloquent Patterns</h3><p><strong>5.1 Scopes:</strong> Encapsulate reusable queries</p><pre>public function scopePublished($query)<br>{<br>    return $query-&gt;whereNotNull(&#39;published_at&#39;);<br>}</pre><p><strong>5.2 Accessors &amp; Mutators:</strong> Handle data transformations</p><pre>public function getFullNameAttribute()<br>{<br>    return &quot;{$this-&gt;first_name} {$this-&gt;last_name}&quot;;<br>}<br>public function setPasswordAttribute($password)<br>{<br>    $this-&gt;attributes[&#39;password&#39;] = Hash::make($password);<br>}</pre><p><strong>5.3 Repository Pattern:</strong> Decouples database operations</p><pre>interface PostRepositoryInterface {<br>    public function findPublished(): Collection;<br>}<br>class EloquentPostRepository implements PostRepositoryInterface {<br>    public function findPublished(): Collection {<br>        return Post::published()-&gt;get();<br>    }<br>}</pre><h3>6. API &amp; Response Best Practices</h3><ul><li>Always use <strong>Resources</strong> or <strong>Resource Collections</strong></li><li>Include <strong>meta-data</strong> and <strong>pagination info</strong></li><li>Transform relationships only when loaded</li></ul><pre>return PostResource::collection($posts)<br>    -&gt;additional([&#39;meta&#39; =&gt; [&#39;total&#39; =&gt; $posts-&gt;total()]]);</pre><p><strong>Error Handling:</strong> Use consistent error structure, e.g.:</p><pre>{<br>  &quot;error&quot;: true,<br>  &quot;message&quot;: &quot;Validation failed&quot;,<br>  &quot;details&quot;: {&quot;email&quot;: [&quot;The email field is required.&quot;]}<br>}</pre><h3>7. Security Hardening</h3><ul><li>Always <strong>hash passwords</strong> (Hash::make)</li><li>Validate and sanitize inputs</li><li>Use <strong>Gates/Policies</strong> for authorization</li><li>Rate-limit APIs with ThrottleRequests middleware</li><li>Protect sensitive logs; never log passwords or tokens</li></ul><h3>8. Advanced Testing Strategies</h3><ul><li><strong>Unit Tests:</strong> Small, isolated logic</li><li><strong>Feature Tests:</strong> Test API endpoints or flows</li><li><strong>Browser/Acceptance Tests:</strong> Laravel Dusk</li><li>Use <strong>Factories</strong> for realistic test data</li></ul><p><strong>Example Feature Test:</strong></p><pre>public function test_user_registration()<br>{<br>    $response = $this-&gt;postJson(&#39;/api/register&#39;, [<br>        &#39;name&#39; =&gt; &#39;John Doe&#39;,<br>        &#39;email&#39; =&gt; &#39;john@example.com&#39;,<br>        &#39;password&#39; =&gt; &#39;secret123&#39;,<br>    ]);<br>    $response-&gt;assertStatus(201);<br>    $this-&gt;assertDatabaseHas(&#39;users&#39;, [&#39;email&#39; =&gt; &#39;john@example.com&#39;]);<br>}</pre><h3>9. Observers &amp; Model Events</h3><p>Use <strong>observers</strong> for automatic tasks on models:</p><pre>class UserObserver<br>{<br>    public function created(User $user)<br>    {<br>        Mail::to($user-&gt;email)-&gt;send(new WelcomeMail($user));<br>    }<br>}</pre><p><strong>Pro Tip:</strong> Observers are cleaner than adding logic inside the model.</p><h3>10. Service Providers &amp; Dependency Injection</h3><ul><li>Use <strong>service providers</strong> to register classes and bindings</li><li>Leverage <strong>constructor injection</strong> instead of static facades when possible</li></ul><pre>public function __construct(UserService $userService)<br>{<br>    $this-&gt;userService = $userService;<br>}</pre><p><strong>Benefits:</strong> Easier testing, better decoupling, clear dependencies</p><h3>11. Event Sourcing &amp; Domain Patterns (Optional for Large Apps)</h3><p>For very large projects:</p><ul><li><strong>Event Sourcing:</strong> Store every state change as an event</li><li><strong>CQRS (Command Query Responsibility Segregation):</strong> Separate commands (writes) from queries (reads)</li><li>Use spatie/laravel-event-sourcing for implementing complex event-driven apps</li></ul><h3>12. Logging, Metrics, &amp; Monitoring</h3><ul><li>Use <strong>Monolog channels</strong> for separate logs</li><li>Integrate <strong>Sentry, Bugsnag, or custom alert systems</strong></li><li>Include <strong>contextual information</strong> for debugging</li><li>Track metrics: request duration, queue processing time, DB query time</li></ul><h3>13. Package Design &amp; Reusability</h3><ul><li>Encapsulate reusable logic in <strong>Laravel packages</strong></li><li>Use <strong>composer autoloading</strong></li><li>Keep dependencies minimal</li><li>Document usage clearly for your team</li></ul><h3>14. Code Readability &amp; Maintainability</h3><ul><li>Follow <strong>PSR-12</strong> standards</li><li>Keep methods <strong>small and single-responsibility</strong></li><li>Comment <strong>why</strong>, not what</li><li>Refactor old code continuously</li><li>Avoid “magic strings” — use constants</li></ul><pre>class UserStatus<br>{<br>    const ACTIVE = &#39;active&#39;;<br>    const INACTIVE = &#39;inactive&#39;;<br>}</pre><h3>15. Performance Optimization Checklist</h3><ul><li>Cache queries, configs, and views</li><li>Use eager-loading and chunking</li><li>Use indexes on DB columns</li><li>Optimize heavy jobs with queues</li><li>Profile with Laravel Telescope or Clockwork</li></ul><h3>16. Conclusion</h3><p>By following these advanced best practices, your Laravel application can be:</p><ul><li><strong>Highly maintainable</strong> — readable code, single responsibility, decoupled services</li><li><strong>Scalable</strong> — queues, caching, events, optimized queries</li><li><strong>Secure</strong> — validation, policies, hashed passwords, rate-limiting</li><li><strong>Testable</strong> — unit tests, feature tests, factories</li><li><strong>Monitoring-friendly</strong> — logging, metrics, alerts</li></ul><p>These practices are what separate <strong>hobby projects</strong> from <strong>production-ready enterprise applications</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2811c5a02b11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Coding Best Practices — 02]]></title>
            <link>https://mktmsameera.medium.com/laravel-coding-best-practices-02-7b7c80ed8f25?source=rss-814e8bc5c3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b7c80ed8f25</guid>
            <dc:creator><![CDATA[M. K. T. M. Sameera]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 15:09:24 GMT</pubDate>
            <atom:updated>2025-09-17T15:09:24.772Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel Coding Best Practices — 02</h3><p>In <a href="https://medium.com/@mktmsameera/laravel-coding-best-practices-01-1e4f4aae8cda">Part 01</a>, we covered <strong>naming conventions</strong>, which is the foundation of clean code. Naming is critical, but once your project grows beyond a few controllers and models, other best practices become just as important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*ukzJgmNNuzwKGaVMOaRprw.png" /></figure><p>In this article, I’ll share <strong>advanced Laravel best practices</strong> I’ve learned from years of real-world development. These practices focus on <strong>maintainability, readability, performance, and long-term scalability</strong>.</p><h3>1. Controllers — Keep Them Lean</h3><p>Controllers in Laravel should primarily handle <strong>request validation and response formatting</strong>. They should <strong>never contain business logic or heavy queries</strong>.</p><p><strong>Why?</strong></p><ul><li>Keeping controllers thin improves readability.</li><li>It makes your code easier to test.</li><li>It prevents duplication when the same logic is needed in multiple controllers.</li></ul><p><strong>Bad Example:</strong></p><pre>public function store(Request $request)<br>{<br>    $user = new User();<br>    $user-&gt;name = $request-&gt;name;<br>    $user-&gt;email = $request-&gt;email;<br>    $user-&gt;save();<br><br>    Mail::to($user-&gt;email)-&gt;send(new WelcomeMail($user));<br>}</pre><p><strong>Problems:</strong></p><ul><li>Validation is missing.</li><li>Business logic (creating user + sending email) is inside controller.</li></ul><p><strong>Better Approach — Service Layer:</strong></p><pre>public function store(UserRequest $request, UserService $userService)<br>{<br>    $user = $userService-&gt;createUser($request-&gt;validated());<br>    return response()-&gt;json($user);<br>}</pre><p><strong>UserService.php:</strong></p><pre>public function createUser(array $data)<br>{<br>    $user = User::create($data);<br>    Mail::to($user-&gt;email)-&gt;send(new WelcomeMail($user));<br>    return $user;<br>}</pre><p><strong>Takeaway:</strong> Controllers should orchestrate actions, not perform them.</p><h3>2. Requests &amp; Validation</h3><p>Always validate using <strong>Form Request classes</strong>, not directly in the controller. This keeps validation <strong>reusable, clean, and testable</strong>.</p><pre>php artisan make:request UserRequest</pre><pre>public function rules(): array<br>{<br>    return [<br>        &#39;name&#39;  =&gt; &#39;required|string|max:255&#39;,<br>        &#39;email&#39; =&gt; &#39;required|email|unique:users,email&#39;,<br>    ];<br>}</pre><p><strong>Pro Tip:</strong> You can even add <strong>authorization logic</strong> in Form Requests, which prevents controllers from bloating:</p><pre>public function authorize(): bool<br>{<br>    return auth()-&gt;user()-&gt;isAdmin();<br>}</pre><h3>3. Models &amp; Relationships</h3><p>Models should primarily represent <strong>data</strong> and <strong>relationships</strong>. Avoid adding business logic here.</p><ul><li>Use <strong>Eloquent relationships</strong> instead of raw queries.</li><li>Always define <strong>inverse relationships</strong> for clarity.</li></ul><pre>// User.php<br>public function posts()<br>{<br>    return $this-&gt;hasMany(Post::class);<br>}</pre><pre>// Post.php<br>public function user()<br>{<br>    return $this-&gt;belongsTo(User::class);<br>}</pre><p><strong>Tip:</strong> Use Eager Loading to avoid N+1 query problems:</p><pre>$users = User::with(&#39;posts&#39;)-&gt;get();</pre><h3>4. Database Migrations &amp; Seeders</h3><p>Never modify the database manually. Always use <strong>migrations</strong>. It allows you to:</p><ul><li>Version control database changes</li><li>Easily set up new environments</li></ul><p><strong>Factories</strong> make generating test data easy:</p><pre>User::factory()-&gt;count(50)-&gt;create();</pre><p><strong>Seeder Tip:</strong> You can use <strong>model relationships in factories</strong>:</p><pre>Post::factory()-&gt;count(10)-&gt;for(User::factory())-&gt;create();</pre><h3>5. API Responses — Use Resources</h3><p>Never return raw models in APIs. Laravel <strong>Resources</strong> give consistent, structured responses.</p><pre>php artisan make:resource UserResource</pre><pre>public function toArray($request)<br>{<br>    return [<br>        &#39;id&#39;    =&gt; $this-&gt;id,<br>        &#39;name&#39;  =&gt; $this-&gt;name,<br>        &#39;email&#39; =&gt; $this-&gt;email,<br>        &#39;posts&#39; =&gt; PostResource::collection($this-&gt;whenLoaded(&#39;posts&#39;)),<br>    ];<br>}</pre><p><strong>Why?</strong></p><ul><li>You control what gets exposed.</li><li>API structure is consistent across endpoints.</li></ul><h3>6. Caching for Performance</h3><p>Frequent queries or heavy computations should use Laravel’s cache system.</p><pre>$users = Cache::remember(&#39;users_all&#39;, 3600, fn() =&gt; User::all());</pre><p><strong>Tip:</strong> Use <strong>tagged caching</strong> if you want to clear related cache easily:</p><pre>Cache::tags([&#39;users&#39;, &#39;posts&#39;])-&gt;flush();</pre><h3>7. Configuration &amp; Environment</h3><ul><li>Never hardcode sensitive values.</li><li>Use .env and config/ files.</li></ul><pre>$apiKey = config(&#39;services.payment.key&#39;);</pre><p><strong>Why?</strong></p><ul><li>Easy to switch between environments (dev, staging, production)</li><li>Keeps secrets out of version control</li></ul><h3>8. Logging &amp; Error Handling</h3><p>Logging is your first line of defense for production issues. Avoid dd() or dump() in production.</p><pre>Log::info(&#39;User created&#39;, [&#39;user_id&#39; =&gt; $user-&gt;id]);<br>Log::error(&#39;Error sending mail&#39;, [&#39;exception&#39; =&gt; $e-&gt;getMessage()]);</pre><p><strong>Pro Tip:</strong> Create a <strong>centralized error handler</strong> for repetitive logging or notifications.</p><h3>9. Testing</h3><p>Testing ensures your code doesn’t break as your application grows. Laravel provides <strong>Feature</strong> and <strong>Unit tests</strong>.</p><pre>php artisan make:test UserTest</pre><p><strong>Example:</strong></p><pre>public function test_user_creation()<br>{<br>    $user = User::factory()-&gt;create();<br>    $this-&gt;assertDatabaseHas(&#39;users&#39;, [&#39;email&#39; =&gt; $user-&gt;email]);<br>}</pre><p><strong>Tip:</strong> Test edge cases, not just happy paths. Tests are your safety net when refactoring.</p><h3>10. Code Readability &amp; Consistency</h3><ul><li>Stick to <strong>naming conventions</strong> (see Part 01).</li><li>Write <strong>single-responsibility methods</strong>.</li><li>Use <strong>PSR-12 coding standard</strong>.</li></ul><p><strong>Why?</strong> Clean code saves time. Messy code works today, but slows you down tomorrow.</p><p><strong>Bonus Tip:</strong> Comment <strong>why</strong>, not <strong>what</strong>. Code explains <em>what</em>, comments explain <em>why</em>.</p><pre>// Why this query exists: Fetch only verified users for promotion email<br>$users = User::where(&#39;is_verified&#39;, true)-&gt;get();</pre><h3>11. Advanced Eloquent Tips</h3><ul><li><strong>Scopes</strong>: Encapsulate common queries.</li></ul><pre>public function scopeVerified($query)<br>{<br>    return $query-&gt;where(&#39;is_verified&#39;, true);<br>}</pre><pre>$users = User::verified()-&gt;get();</pre><ul><li><strong>Accessors &amp; Mutators</strong>: Handle data transformations cleanly.</li></ul><pre>public function getFullNameAttribute()<br>{<br>    return &quot;{$this-&gt;first_name} {$this-&gt;last_name}&quot;;<br>}</pre><ul><li><strong>Mass Assignment Protection</strong>: Use $fillable instead of $guarded for better security.</li></ul><h3>12. Security Best Practices</h3><ul><li>Use bcrypt or Hash::make() for passwords.</li><li>Validate user input — never trust request data.</li><li>Protect against SQL injection by using Eloquent or query builder.</li><li>Use gate and policy for authorization.</li></ul><h3>Conclusion</h3><p>Laravel is elegant and powerful, but elegance doesn’t automatically mean maintainable. Following these best practices — thin controllers, form requests, resource responses, caching, testing, and security — will make your code <strong>scalable, readable, and robust</strong>.</p><p>Next, in <strong>Part 3</strong>, we’ll cover <strong>performance optimization, event-driven architecture, and advanced Laravel patterns</strong> to take your applications to the next level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b7c80ed8f25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Error Notifier: Get Instant Error Alerts on Discord, WhatsApp, Slack, and Email]]></title>
            <link>https://mktmsameera.medium.com/laravel-error-notifier-get-instant-error-alerts-on-discord-whatsapp-slack-and-email-553905b0e5f5?source=rss-814e8bc5c3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/553905b0e5f5</guid>
            <dc:creator><![CDATA[M. K. T. M. Sameera]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 14:50:37 GMT</pubDate>
            <atom:updated>2025-09-17T14:50:37.187Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tPUa4viTLcv0sfaqfwtKA.png" /></figure><p>Running a Laravel application in production is exciting — until an unexpected error breaks something and you only find out hours later when users start complaining. Logs are helpful, yes, but unless you’re glued to them, critical issues can slip under the radar.</p><p>That’s exactly why I built <a href="https://github.com/mktmsameera/laravel-error-notifier"><strong>laravel-error-notifier</strong></a>—a simple Laravel package that sends real-time error notifications directly to <strong>Discord, WhatsApp, Slack, or Email</strong>. Instead of constantly checking log files, you get instant alerts in the tools you already use every day.</p><h3>Why I Created Laravel Error Notifier</h3><p>Popular platforms like Sentry or Bugsnag are excellent for enterprise setups, but they can feel too heavy or expensive for small-to-medium Laravel projects. I wanted something:</p><ul><li><strong>Simple</strong>: install and start getting alerts with minimal setup.</li><li><strong>Flexible</strong>: support multiple channels (Discord, WhatsApp, Slack, Email).</li><li><strong>Lightweight</strong>: no bloated dependencies or vendor lock-in.</li></ul><p>This package solves that by plugging into Laravel’s exception system and pushing alerts to wherever you and your team hang out.</p><h3>Supported Notification Channels</h3><p>Here’s what you can do with laravel-error-notifier:</p><ul><li><strong>Discord</strong> — Send detailed error messages to your server’s channel. Perfect for dev teams already using Discord for project updates.</li><li><strong>Slack</strong> — Get error alerts directly in your Slack workspace. Keep production monitoring where your daily team discussions happen.</li><li><strong>WhatsApp</strong> — For smaller teams or personal projects, WhatsApp alerts make sure you never miss a critical issue on your phone.</li><li><strong>Email</strong> — A classic option — reliable and straightforward for admins or support teams.</li></ul><p>You can choose one or multiple channels depending on your workflow.</p><h3>Installation</h3><p>Install via Composer:</p><pre>composer require mktmsameera/laravel-error-notifier</pre><p>Then publish the config file:</p><pre>php artisan vendor:publish --provider=&quot;Mktmsameera\LaravelErrorNotifier\LaravelErrorNotifierServiceProvider&quot;</pre><p>This gives you a config file where you define your preferred notification channels.</p><h3>Example Configurations</h3><h3>Email Alerts</h3><pre>return [<br>    &#39;channels&#39; =&gt; [<br>        &#39;mail&#39; =&gt; [<br>            &#39;to&#39; =&gt; &#39;your-email@example.com&#39;,<br>        ],<br>    ],<br>];</pre><p>Whenever an exception occurs, you’ll instantly receive an email with the stack trace and error details.</p><h3>Slack Alerts</h3><pre>return [<br>    &#39;channels&#39; =&gt; [<br>        &#39;slack&#39; =&gt; [<br>            &#39;webhook_url&#39; =&gt; env(&#39;SLACK_WEBHOOK_URL&#39;),<br>        ],<br>    ],<br>];</pre><p>Just set your Slack webhook URL and errors will land in your chosen Slack channel.</p><h3>Discord Alerts</h3><pre>return [<br>    &#39;channels&#39; =&gt; [<br>        &#39;discord&#39; =&gt; [<br>            &#39;webhook_url&#39; =&gt; env(&#39;DISCORD_WEBHOOK_URL&#39;),<br>        ],<br>    ],<br>];</pre><p>This pushes structured error messages to your Discord server, making monitoring seamless.</p><h3>WhatsApp Alerts</h3><p>For WhatsApp, you can integrate with your preferred gateway (like Twilio or WhatsApp Business API):</p><pre>return [<br>    &#39;channels&#39; =&gt; [<br>        &#39;whatsapp&#39; =&gt; [<br>            &#39;number&#39; =&gt; env(&#39;WHATSAPP_NUMBER&#39;),<br>            &#39;api_key&#39; =&gt; env(&#39;WHATSAPP_API_KEY&#39;),<br>        ],<br>    ],<br>];</pre><p>Once configured, you’ll receive real-time error messages right on your phone.</p><h3>Why This Package Helps Developers</h3><ul><li><strong>Immediate response</strong> — Errors don’t sit hidden in logs for days.</li><li><strong>No learning curve</strong> — It’s simple to integrate with Laravel’s existing exception handler.</li><li><strong>Team collaboration</strong> — Send errors to the exact platform your team uses — Discord, Slack, WhatsApp, or Email.</li><li><strong>Customizable</strong> — Decide which errors should trigger alerts, and fine-tune per channel.</li></ul><h3>Open Source and Free</h3><p>The package is open source and available for everyone:</p><ul><li>GitHub: <a href="https://github.com/mktmsameera/laravel-error-notifier">https://github.com/mktmsameera/laravel-error-notifier</a></li><li>Packagist: <a href="https://packagist.org/packages/mktmsameera/laravel-error-notifier">https://packagist.org/packages/mktmsameera/laravel-error-notifier</a></li></ul><p>Feel free to explore the code, use it in your projects, or even contribute improvements.</p><h3>Final Thoughts</h3><p>Error handling is critical in any production environment. With <strong>laravel-error-notifier</strong>, you don’t need to babysit logs or rely on heavy third-party services. Instead, you get <strong>real-time error alerts</strong> delivered to <strong>Discord, WhatsApp, Slack, or Email</strong> — keeping you informed and your application stable.</p><p>👉 Give it a try and let me know your feedback:</p><ul><li><a href="https://github.com/mktmsameera/laravel-error-notifier">GitHub Repository</a></li><li><a href="https://packagist.org/packages/mktmsameera/laravel-error-notifier">Packagist Page</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=553905b0e5f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JOSE — JSON Object Signing and Encryption (JWT, JWS, JWE, JWK, JWA)]]></title>
            <link>https://mktmsameera.medium.com/jose-json-object-signing-and-encryption-jwt-jws-jwe-jwk-jwa-cb58d0e303b2?source=rss-814e8bc5c3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb58d0e303b2</guid>
            <category><![CDATA[jwt-auth]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[jwt-token]]></category>
            <category><![CDATA[jwe]]></category>
            <dc:creator><![CDATA[M. K. T. M. Sameera]]></dc:creator>
            <pubDate>Wed, 24 Aug 2022 09:22:10 GMT</pubDate>
            <atom:updated>2022-08-24T09:22:10.097Z</atom:updated>
            <content:encoded><![CDATA[<h3>JOSE — JSON Object Signing and Encryption (JWT, JWS, JWE, JWK, JWA)</h3><p><strong>JOSE framework and its specifications</strong></p><p>JOSE (Javascript Object Signing and Encryption) is a framework used to secure transfer claims between any two parties. JWA, JWK, JWS, JWE, JWT are standards of JOSE. However, these are built on JSON for easy use in web applications.</p><ul><li><a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40">JWA</a> — JSON Web Algorithms</li><li><a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-key-41">JWK</a> — JSON Web Key</li><li><a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41">JWS</a> — JSON Web Signature</li><li><a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40">JWE</a> — JSON Web Encryption</li><li><a href="http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32">JWT</a> — JSON Web Token</li></ul><h3>JWT — JSON Web Token</h3><p>JWT is a standard mechanism used for authentication. It provides a set of key/value pairs as claims. There are three components in the token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*e0gaQwdmN3COLPa3" /></figure><p><strong>header :-</strong></p><p>The header is used to identify the algorithm to generate a signature</p><p><strong>payload:-</strong></p><p>The payload consists of the claims and signature (secret key). The secret key used to validate the token.</p><p><strong>signature:-</strong></p><p>The structure consists of the information that could be Serialized or Deserialized.</p><p>Sample token:</p><blockquote>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c</blockquote><p>Available algorithms:</p><p>HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512</p><p>header:</p><blockquote>{</blockquote><blockquote>“alg” : “HS256”,</blockquote><blockquote>“typ” : “JWT”</blockquote><blockquote>}</blockquote><blockquote>payload:</blockquote><blockquote>{</blockquote><blockquote>“id” : 123456789,</blockquote><blockquote>“name” : “Sameera”</blockquote><blockquote>}</blockquote><blockquote>signature:</blockquote><blockquote>OpOSSw7e485LOP5PrzScxHb7SR6sAOMRckfFwi4rp7o</blockquote><h3>JWS — JSON Web Signature</h3><p>JWS is used to represent content secured with digital signatures and Hash-based Message Authentication Codes (HMACs). The JWS header contains an algorithm. There are three components in JWS token. Header, payload and signature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*BiD7qnvZ3nqB6t5E" /></figure><p>header :</p><p>JWS Protected Header as BASE64URL(UTF8(JWS Protected</p><p>Header)) gives this value</p><p>Payload:</p><p>Encode payload as bas64url</p><p>Signature:</p><p>on signing with the HMAC SHA-256 algorithm and base64url encoding, gives the Encoded JWS Signature value</p><p>Sample token:</p><blockquote><em>eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk</em></blockquote><h3>JWE — JSON Web Encryption</h3><p>JSON Web Encryption (JWE) represents encrypted content using JSON-based data structures. This token can read only the intended recipient. There are five main components here. All these components are base64url encoded.</p><ol><li>JOSE header</li><li>JWE Encrypted Key</li><li>JWE initialization vector</li><li>JWE Ciphertext</li><li>JWE Authentication Tag</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jhFeBPwbXmDEOvVM" /></figure><p>Header:</p><p>header contain algorithm and encryption keys(CEK)</p><p>Encryption key:</p><p>During the encryption process, the issuer generates a random key, which is 256-bits in size, that is used to encrypt the message. This is placed in the JWE Encrypted key section.</p><p>Initialization vector:</p><p>Some encryption algorithms require an additional random generated number(initialization vector) to encrypt data with the secret key. The recipient requires this vector to decrypt the message.</p><p>Ciphertext:</p><p>Ciphertext that is computed by encrypting the plaintext JSON payload.</p><p>Authentication tag:</p><p>This will be generated along with the ciphertext. It ensures the integrity of the ciphertext.</p><blockquote>Sample token:</blockquote><blockquote><em>eyJhbGciOiJFQ0RILUVTK0EyNTZLVyIsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJraWQiOiJfOTF1OGtESTRVRUhmT2FGUHAyZGQyWUlsbGRpa1BWSzQybGR3T0FUQUpvIiwidHlwIjoiSldFIn0.H5dSdEDWjBOXRfrpDLcz_Mn4m7EAVKhzCRyfWCLHXOe4OhvIkV3KCMldkQL1wHJidQ8E7qOW1ImFaK36BJflyaVhCQd0o5RT.cT83StoZ09exRsLBh17LYg.y5Dnz7bt17nHKPDaUR3sT3KFuIepzHPOCcv09xnK3BzKu1gicsjbTBG16Hk9WilfX8nVt78Hw2NKhANGQ59W09fvtIYlVX2gSQHsJR6dfgXqxrPa7hUbV1qCHjgV1i6Slfcn7oXoh69fHvVUJfxD7TfcVFebs1iskP_6U2bzbak51TsUn-R0v-oF8VUajK3vjteVcgov7aqhSitZW6Hnbw.BVZ3Z6hVhRDKEZ0HBIafqkF5ZfYgMr3fZ1oqRfd1OvA</em></blockquote><h3>JWK — JSON Web Key</h3><p>A JSON Web Key (JWK) represents a cryptographic key.</p><p>Sample key</p><blockquote><em>{</em></blockquote><blockquote><em>“kty”:”EC”,</em></blockquote><blockquote><em>“crv”:”P-256&quot;,</em></blockquote><blockquote><em>“x”:”MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4&quot;,</em></blockquote><blockquote><em>“y”:”4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM”,</em></blockquote><blockquote><em>“use”:”enc”,</em></blockquote><blockquote><em>“kid”:”1&quot;</em></blockquote><blockquote><em>}</em></blockquote><p>The cryptographic algorithm(kty) is mandatory in the key. But cryptographic algorithm family used with the key, such as “RSA” or “EC”. The JWK Key Objects are stored within the array of the JWK Container object.</p><h3>JWA — JSON Web Algorithms</h3><p>JSON Web Algorithms defines algorithms and their identifiers to be used in JWS and JWE</p><p><strong>-Algorithms for JWS</strong></p><blockquote>HS256, HS384, HS512 (HMAC with SHA),</blockquote><blockquote>RS256, RS384, RS512 (RSASSA-PKCS-v1_5 with SHA),</blockquote><blockquote>ES256, ES384, ES512 (ECDSA with SHA),</blockquote><blockquote>PS256, PS384, PS512 (RSASSA-PSS with SHA for digest and MGF1)</blockquote><p><strong>-Algorithms for JWE</strong></p><blockquote>RSA1_5, RSA-OAEP, RSA-OAEP-256,</blockquote><blockquote>A128KW, A192KW, A256KW (AES Keywrap),</blockquote><blockquote>dir (direct encryption),</blockquote><blockquote>ECDH-ES (EC Diffie Hellman Ephemeral+Static key agreement),</blockquote><blockquote>ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW (with AES Keywrap),</blockquote><blockquote>A128GCMKW, A192GCMKW, A256GCMKW (AES in GCM Keywrap),</blockquote><blockquote>PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW</blockquote><blockquote>(PBES2 with HMAC SHA and AES keywrap)</blockquote><blockquote>A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 (AES in CBC with HMAC),</blockquote><blockquote>A128GCM, A192GCM, A256GCM</blockquote><p><strong>-Algorithms for JWK</strong></p><blockquote>Elliptic Curve</blockquote><blockquote>RSA</blockquote><blockquote>Octet sequence key type</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb58d0e303b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upload Image To Google Cloud Storage]]></title>
            <link>https://mktmsameera.medium.com/upload-image-to-google-cloud-storage-f045c34bbfa4?source=rss-814e8bc5c3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/f045c34bbfa4</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-cloud-storage]]></category>
            <category><![CDATA[php-developers]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[M. K. T. M. Sameera]]></dc:creator>
            <pubDate>Tue, 26 Jan 2021 16:24:14 GMT</pubDate>
            <atom:updated>2021-01-26T16:24:14.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*9DLsuM0ZIwsCaFptiXK4xw.jpeg" /></figure><p>Google Cloud Storage is an object storage in the cloud.</p><p><strong>01) install the laravel package</strong></p><blockquote>$ composer require superbalist/laravel-google-cloud-storage</blockquote><p><strong>02) add superbalist provider to the config/app.php</strong></p><blockquote>‘providers’ =&gt; [</blockquote><blockquote>…</blockquote><blockquote>Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,</blockquote><blockquote>…</blockquote><blockquote>],</blockquote><p><strong>03) add a new disk to the config/filesystem.php</strong></p><blockquote>‘disks’ =&gt; [</blockquote><blockquote>…</blockquote><blockquote>‘gcs’ =&gt; [</blockquote><blockquote>‘driver’ =&gt; ‘gcs’,</blockquote><blockquote>‘project_id’ =&gt; env(‘GOOGLE_CLOUD_PROJECT_ID’, ‘your-project-id’),</blockquote><blockquote>‘key_file’ =&gt; env(‘GOOGLE_CLOUD_KEY_FILE’, null),</blockquote><blockquote>‘bucket’ =&gt; env(‘GOOGLE_CLOUD_STORAGE_BUCKET’, ‘your-bucket’),</blockquote><blockquote>‘path_prefix’ =&gt; env(‘GOOGLE_CLOUD_STORAGE_PATH_PREFIX’, null), // optional</blockquote><blockquote>‘storage_api_uri’ =&gt; env(‘GOOGLE_CLOUD_STORAGE_API_URI’, null),</blockquote><blockquote>],</blockquote><blockquote>],</blockquote><p><em>There are five environment variables you have to set,</em></p><ul><li><strong>GOOGLE_CLOUD_PROJECT_ID : GCP project id</strong></li><li><strong>GOOGLE_CLOUD_KEY_FILE : JSON key file</strong></li></ul><p><em>You can add this as a array also like below ,</em></p><blockquote>‘key_file’ =&gt; [</blockquote><blockquote>‘type’ =&gt; env(‘GOOGLE_CLOUD_ACCOUNT_TYPE’),</blockquote><blockquote>‘private_key_id’ =&gt; env(‘GOOGLE_CLOUD_PRIVATE_KEY_ID’),</blockquote><blockquote>‘private_key’ =&gt; env(‘GOOGLE_CLOUD_PRIVATE_KEY’),</blockquote><blockquote>‘client_email’ =&gt; env(‘GOOGLE_CLOUD_CLIENT_EMAIL’),</blockquote><blockquote>‘client_id’ =&gt; env(‘GOOGLE_CLOUD_CLIENT_ID’),</blockquote><blockquote>‘auth_uri’ =&gt; env(‘GOOGLE_CLOUD_AUTH_URI’),</blockquote><blockquote>‘token_uri’ =&gt; env(‘GOOGLE_CLOUD_TOKEN_URI’),</blockquote><blockquote>‘auth_provider_x509_cert_url’ =&gt; env(‘GOOGLE_CLOUD_AUTH_PROVIDER_CERT_URL’),</blockquote><blockquote>‘client_x509_cert_url’ =&gt; env(‘GOOGLE_CLOUD_CLIENT_CERT_URL’),</blockquote><blockquote>],</blockquote><ul><li><strong>GOOGLE_CLOUD_STORAGE_BUCKET : your bucket name</strong></li><li><strong>GOOGLE_CLOUD_STORAGE_PATH_PREFIX : your image path in the bucket</strong></li><li><strong>GOOGLE_CLOUD_STORAGE_API_URI : your custom domain, you don’t need to set this now.</strong></li></ul><p><em>Example for upload image to the Google Cloud Storage,</em></p><p><strong>Create a controller</strong></p><blockquote>Php artisan make:controller UserProfileController</blockquote><p><strong>create a method named update which stores the uploaded image file to GCS</strong></p><blockquote>namespace App\Http\Controllers;</blockquote><blockquote>use Illuminate\Http\Request;</blockquote><blockquote>use Illuminate\Support\Facades\Storage;</blockquote><blockquote>class UserProfileController extends Controller</blockquote><blockquote>{</blockquote><blockquote>/**</blockquote><blockquote>* Upload user profile image</blockquote><blockquote>*</blockquote><blockquote>* @param Request $request</blockquote><blockquote>* @return Response</blockquote><blockquote>*/</blockquote><blockquote>public function updateProfile(Request $request)</blockquote><blockquote>{</blockquote><blockquote>$disk = Storage::disk(‘gcs’);</blockquote><blockquote>// create a file</blockquote><blockquote>$profile = $request-&gt;file(‘user_profile’);</blockquote><blockquote>$disk-&gt;put(‘profile’, $profile);</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p><strong>Create endpoint (routes/web.php)</strong></p><blockquote>Route::post(‘/updateProfile, UserProfileController@updateProfile);</blockquote><p><strong><em>Other functions</em></strong></p><p>// create a file</p><p>$disk-&gt;put(‘avatars/1’, $fileContents);</p><p>// create a file with custom name</p><p>$disk-&gt;putFileAs(‘profile’, $profile, ‘file.jpg’);</p><p>// check if a file exists</p><p>$exists = $disk-&gt;exists(‘file.jpg’);</p><p>// get file modification date</p><p>$time = $disk-&gt;lastModified(‘file1.jpg’);</p><p>// copy a file</p><p>$disk-&gt;copy(‘old/file1.jpg’, ‘new/file1.jpg’);</p><p>// move a file</p><p>$disk-&gt;move(‘old/file1.jpg’, ‘new/file1.jpg’);</p><p>// get url to file</p><p>$url = $disk-&gt;url(https://medium.com/%E2%80%98folder/my_file.txt%E2%80%99);</p><p>// Set the visibility of file to public</p><p>$disk-&gt;setVisibility(‘folder/my_file.txt’, ‘public’);</p><p>// delete a file</p><p>$exists = $disk-&gt;delete(‘file.jpg’);</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f045c34bbfa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Coding Best Practices — 01]]></title>
            <link>https://mktmsameera.medium.com/laravel-coding-best-practices-01-1e4f4aae8cda?source=rss-814e8bc5c3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e4f4aae8cda</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[M. K. T. M. Sameera]]></dc:creator>
            <pubDate>Fri, 20 Nov 2020 17:34:45 GMT</pubDate>
            <atom:updated>2020-11-20T17:34:45.727Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel Coding Best Practices — 01</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*yVT2vAQvz3zuB0IUtH0NiA.jpeg" /></figure><h3>Naming</h3><blockquote>Everything has a name. Even In computer programming, we have to use naming. For naming codes, there are a few rules. Some rules depend on the programming language. The name must be meaningful</blockquote><p>For each type of naming, we use different standard naming opportunities. There are four main case types.</p><blockquote><strong>camelCase</strong> — must start with a lowercase letter and the first letter of every new subsequent word has its first letter capitalized and is compounded with the previous word.</blockquote><blockquote><strong>snake_case — </strong>replacing all spaces with a “_” and lowercasing all the words.</blockquote><blockquote><strong>kebab-case — </strong>replacing all spaces with a “-” and lowercasing all the words.</blockquote><blockquote><strong>PascalCase — </strong>every word starts with an uppercase letter</blockquote><h3>Laravel variable naming Conventions</h3><blockquote><strong>Controllers</strong></blockquote><blockquote>Name should be singular and pascal case</blockquote><blockquote>Example :- UserController, PostController</blockquote><blockquote><strong>Database tables</strong></blockquote><blockquote>Name should be plural and snake case</blockquote><blockquote>Example :- users, user_posts</blockquote><blockquote>Table columns</blockquote><blockquote>Name should be singular and snake case</blockquote><blockquote>Example :- id, post_content, created_at</blockquote><blockquote>Variables</blockquote><blockquote>Name should be camelCase</blockquote><blockquote>Example :- $users, $usersPosts</blockquote><blockquote>Models</blockquote><blockquote>Name should be singular and pascal case</blockquote><blockquote>Example :- NewsPost, FormPost</blockquote><blockquote>Views</blockquote><blockquote>Name should be snake case</blockquote><blockquote>Example :- user_home.blade.php, all_post.blade.php</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e4f4aae8cda" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>