<?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 Abd. Asis on Medium]]></title>
        <description><![CDATA[Stories by Abd. Asis on Medium]]></description>
        <link>https://medium.com/@idabdasis?source=rss-738054c1cda2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*keIyyi1KdIUsVEKZ6RmXVA.jpeg</url>
            <title>Stories by Abd. Asis on Medium</title>
            <link>https://medium.com/@idabdasis?source=rss-738054c1cda2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:49:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@idabdasis/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 Observers vs Event Listeners — When to Use Which]]></title>
            <link>https://medium.com/@idabdasis/laravel-observers-vs-event-listeners-when-to-use-which-22f8eabdff3d?source=rss-738054c1cda2------2</link>
            <guid isPermaLink="false">https://medium.com/p/22f8eabdff3d</guid>
            <dc:creator><![CDATA[Abd. Asis]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 04:36:45 GMT</pubDate>
            <atom:updated>2026-06-08T04:36:45.901Z</atom:updated>
            <content:encoded><![CDATA[<p>Laravel Observers vs Event Listeners — When to Use Which</p><p>Every Laravel project eventually reaches a point where a model save needs to trigger something else — send a notification, log an activity, update a related record. The framework offers two paths: Observers and Event Listeners. They look similar at first glance, and mixing them up is one of the most common sources of architectural debt in Laravel apps.</p><p>This article breaks down the fundamental difference, when each one shines, and how to combine them without creating a maintenance nightmare.</p><h3>What an Observer Actually Is</h3><p>An <strong>Observer</strong> is a class that hooks into the lifecycle events of a single Eloquent model. When you save, update, delete, or restore a model, Laravel fires a corresponding method on the observer automatically.</p><p>Think of it as the model’s dedicated assistant — it watches everything that happens to that model and reacts.</p><pre>// app/Models/Course.php<br>use App\Observers\CourseObserver;<br>use Illuminate\Database\Eloquent\Attributes\ObservedBy;</pre><pre>#[ObservedBy([CourseObserver::class])]<br>class Course extends Model<br>{<br>    protected $fillable = [&#39;title&#39;, &#39;slug&#39;, &#39;status&#39;, &#39;user_id&#39;];<br>}</pre><p>The #[ObservedBy] attribute (available since Laravel 11) registers the observer directly on the model. You can also register multiple observers by passing an array.</p><pre>// app/Observers/CourseObserver.php<br>class CourseObserver<br>{<br>    public function creating(Course $course): void<br>    {<br>        if (empty($course-&gt;slug)) {<br>            $course-&gt;slug = Str::slug($course-&gt;title);<br>        }<br>    }</pre><pre>    public function updated(Course $course): void<br>    {<br>        if ($course-&gt;wasChanged(&#39;status&#39;) &amp;&amp; $course-&gt;status === &#39;published&#39;) {<br>            ActivityLog::log(&#39;course_published&#39;, $course);<br>        }<br>    }<br>}</pre><p>Observers don’t need manual dispatch — they fire automatically. When you write Course::create([...]), Laravel checks if any observer is registered and invokes the matching method. No extra wiring required.</p><h3>What an Event Listener Actually Is</h3><p>An <strong>Event Listener</strong> responds to a custom event class that you dispatch explicitly in your code. Unlike observers, events are not tied to any model — they can be triggered from a controller, a job, a command, or even another listener.</p><p>An event represents a domain action that happened. A listener handles the side effect of that action.</p><pre>// app/Events/CoursePublished.php<br>class CoursePublished<br>{<br>    public function __construct(<br>        public Course $course,<br>        public User $author,<br>    ) {}<br>}</pre><pre>// app/Listeners/NotifyEnrolledStudents.php<br>class NotifyEnrolledStudents<br>{<br>    public function handle(CoursePublished $event): void<br>    {<br>        $enrolled = $event-&gt;course-&gt;enrollments()-&gt;with(&#39;user&#39;)-&gt;get();</pre><pre>        foreach ($enrolled as $enrollment) {<br>            $enrollment-&gt;user-&gt;notify(<br>                new NewLessonAvailable($event-&gt;course)<br>            );<br>        }<br>    }<br>}</pre><p>You dispatch it explicitly when the business action completes:</p><pre>CoursePublished::dispatch($course, $request-&gt;user());</pre><p>Multiple listeners can react to the same event. One sends email, another pushes a webhook, a third updates a search index. The event class itself carries the data; each listener does one thing with it.</p><h3>Core Differences at a Glance</h3><p>| Aspect | Observers | Event Listeners |</p><p>| — -| — -| — -|</p><p>| Scope | Single Eloquent model lifecycle | Anywhere in the app |</p><p>| Trigger | Automatic on model events | Explicit dispatch |</p><p>| Typical use | Slug generation, audit logs, syncing fields | Email, webhooks, cross-module workflows |</p><p>| Model coupling | Tight — tied to one model | Decoupled — reacts to domain events |</p><p>| Event types | Predefined: creating, created, updating, updated, saving, saved, deleting, deleted, restoring, restored, retrieved | Custom classes with any properties |</p><p>| Registration | #[ObservedBy] attribute or Model::observe() | EventServiceProvider or auto-discovery |</p><p>| Queuing | Synchronous by default (must dispatch jobs inside) | Built-in with ShouldQueue and ShouldQueueAfterCommit |</p><p>| Transaction safety | Runs inside the model’s DB transaction | Can be deferred with ShouldQueueAfterCommit |</p><p>| Testing | Test by creating/updating models and asserting side effects | Event::fake() and assert dispatch or listener behavior |</p><p>The table isn’t meant to declare a winner. It shows two tools with different design constraints. Picking the wrong one creates the kind of code smell that makes you dread adding a new feature.</p><h3>Real Scenario: A Course Platform</h3><p>Instead of abstract examples, let’s walk through a concrete scenario. You’re building a learning platform. Instructors create <strong>Courses</strong>, and each course has <strong>Lessons</strong>. When a course is published, several things need to happen:</p><p>1. Generate a slug from the title</p><p>2. Log the publish activity</p><p>3. Notify all enrolled students</p><p>4. Index the course in Algolia for search</p><p>5. Update the instructor’s public profile stats</p><p>Here’s how the decision tree works.</p><h3>Observer for Persistence Concerns</h3><p>Steps 1 and 2 are directly tied to the Course model — they should always happen when the course changes, regardless of context.</p><pre>class CourseObserver<br>{<br>    public function creating(Course $course): void<br>    {<br>        $course-&gt;uuid = (string) Str::uuid();<br>        $course-&gt;slug = Str::slug($course-&gt;title);<br>    }</pre><pre>    public function saving(Course $course): void<br>    {<br>        if ($course-&gt;isDirty(&#39;title&#39;) &amp;&amp; !$course-&gt;isDirty(&#39;slug&#39;)) {<br>            $course-&gt;slug = Str::slug($course-&gt;title);<br>        }<br>    }<br>}</pre><p>This keeps the controller clean. No controller action ever needs to call Str::slug() manually.</p><h3>Event + Listeners for Side Effects</h3><p>Steps 3, 4, and 5 are external side effects. They should not block the request, and they should not be coupled to the Course model’s observer.</p><pre>// app/Events/CoursePublished.php<br>class CoursePublished<br>{<br>    public function __construct(<br>        public Course $course,<br>    ) {}<br>}</pre><pre>// app/Listeners/SendCoursePublishedNotification.php<br>class SendCoursePublishedNotification implements ShouldQueue, ShouldBeUnique<br>{<br>    public function handle(CoursePublished $event): void<br>    {<br>        $event-&gt;course-&gt;enrollments()<br>            -&gt;with(&#39;user&#39;)<br>            -&gt;lazy()<br>            -&gt;each(fn ($enrollment) =&gt; $enrollment-&gt;user-&gt;notify(<br>                new CoursePublishedNotification($event-&gt;course)<br>            ));<br>    }</pre><pre>    public function uniqueId(): string<br>    {<br>        return &#39;course-published-&#39; . $this-&gt;course-&gt;id;<br>    }<br>}</pre><pre>// app/Listeners/UpdateSearchIndex.php<br>class UpdateSearchIndex implements ShouldQueue<br>{<br>    public function handle(CoursePublished $event): void<br>    {<br>        $event-&gt;course-&gt;searchable();<br>    }<br>}</pre><p>Each listener handles exactly one concern. A new requirement — say, posting to the instructor’s X (Twitter) account — means adding a new listener, not modifying an existing class.</p><p>Now the observer fires the event after a successful publish:</p><pre>class CourseObserver<br>{<br>    public function saved(Course $course): void<br>    {<br>        if ($course-&gt;wasChanged(&#39;status&#39;) &amp;&amp; $course-&gt;status === &#39;published&#39;) {<br>            CoursePublished::dispatch($course);<br>        }<br>    }<br>}</pre><p>This is the sweet spot: the observer detects the change (it’s already watching the model), and delegates the side effects to queued listeners.</p><h3>Key Gotchas</h3><h3>Observer runs inside the model’s transaction</h3><p>If your model saves inside a database transaction and the transaction later rolls back, the observer’s side effects have already happened. Emails sent inside created() won&#39;t be unsent.</p><pre>// Risky — email goes out mid-transaction<br>public function created(Course $course): void<br>{<br>    Mail::send(...); // Sent even if the outer transaction rolls back<br>}</pre><p><strong>Fix:</strong> Use ShouldDispatchAfterCommit on dispatched events inside observers, or queue listeners with ShouldQueueAfterCommit so they only execute after the transaction commits.</p><h3>Observers can become god classes</h3><p>If your CourseObserver contains email logic, cache invalidation, search indexing, and Slack notifications, it has stopped being an observer and has become a dumping ground.</p><p><strong>Fix:</strong> Keep observers lean. If a method in your observer does more than three things, extract it to an event + listener.</p><h3>Listeners queued inside transactions see stale data</h3><p>A queued listener that fires before the transaction commits will not see the new data. The ShouldQueueAfterCommit contract ensures the listener only runs after the database transaction completes.</p><pre>use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;</pre><pre>class SendCoursePublishedNotification implements ShouldQueue, ShouldQueueAfterCommit<br>{<br>    // ...<br>}</pre><h3>Over-dispatched events</h3><p>If every part of your system dispatches CoursePublished, you lose the ability to reason about when and why it fires. Be deliberate about where the dispatch happens — typically at the boundary of a controller or a command handler, not scattered across the codebase.</p><h3>When to Choose What</h3><p>Use an <strong>Observer</strong> when:</p><ul><li>The logic is tied to a model’s persistence lifecycle</li><li>It must run automatically on every create/update/delete of that model</li><li>It concerns data integrity (slugs, UUIDs, default values, sync fields)</li></ul><p>Use an <strong>Event + Listener</strong> when:</p><ul><li>The logic is a side effect that could fail independently</li><li>Multiple actions need to react to the same trigger</li><li>The trigger can come from multiple places (CLI, API, admin panel)</li><li>The reaction should be queued or deferred</li></ul><p>Both tools are valid and frequently coexist. The rule of thumb: if the reaction belongs to the database layer, use an observer. If it belongs to the application or infrastructure layer, use an event.</p><h3>Practical Tips</h3><ul><li>**Name listeners by what they do.** `SendCoursePublishedNotification` is better than `CourseListener`. One concern per class.</li><li>**Use `ShouldBeUnique` for idempotency.** Prevent duplicate notifications if the same event dispatches twice.</li><li>**Cache the event list in production.** `php artisan event:cache` compiles all listeners into a single array — no autodiscovery overhead in production.</li><li>**Test with `Event::fake()` in feature tests.** Assert that specific events were dispatched with the right payload, then test listeners in isolation with unit tests.</li><li>**PHP type hints are not optional.** Laravel resolves the listener’s `handle()` method parameter from the type hint. Omitting it means the listener receives nothing.</li></ul><p>Observers and Event Listeners solve different problems. Observers handle the model’s own lifecycle with zero ceremony. Events and Listeners handle everything else — queued, decoupled, and independently testable. The best Laravel codebases use both, and they keep each one in its lane.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22f8eabdff3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Using These Outdated PHP Functions in PHP 8+]]></title>
            <link>https://medium.com/@idabdasis/stop-using-these-outdated-php-functions-in-php-8-f88c70bd63e5?source=rss-738054c1cda2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f88c70bd63e5</guid>
            <category><![CDATA[php-8]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Abd. Asis]]></dc:creator>
            <pubDate>Wed, 11 Jun 2025 06:26:38 GMT</pubDate>
            <atom:updated>2025-06-11T06:27:46.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*uhhqlMsTJU7W9etpzjg99A.jpeg" /></figure><h3>A Practical Guide to Modernizing Legacy PHP Code (PHP 8.0–8.4)</h3><p>If you’re still maintaining old PHP projects in 2025, you’re probably bumping into some ancient functions that PHP has finally decided to bury. Some are already gone, others are throwing fatal errors, and a few more are standing at the edge of a cliff, waiting to be pushed off in PHP 9.0.</p><p>This article is your go-to checklist for spotting and replacing those legacy PHP landmines — fast. Bookmark it, use it on your next refactor sprint, and let your future self thank you later.</p><h3>1. mysql_* Functions — Long Dead, Still Haunting</h3><p><strong>Status:</strong> Gone since PHP 7.0, completely removed in PHP 8+<br> <strong>Why it’s bad:</strong> No support for prepared statements, Unicode, SSL, or literally any good practice.</p><p><strong>What to use instead:</strong></p><p><strong>PDO</strong> — Preferred for abstraction, better error handling, and clean syntax.</p><p><strong>MySQLi</strong> — Great if you want something procedural and lightweight.</p><pre>// ❌ Old (mysql_* — do not use)<br>$result = mysql_query(&quot;SELECT * FROM users WHERE id = $id&quot;);<br><br>// ✅ Modern (PDO)<br>$stmt = $pdo-&gt;prepare(&#39;SELECT * FROM users WHERE id = :id&#39;);<br>$stmt-&gt;execute([&#39;id&#39; =&gt; $id]);<br>$user = $stmt-&gt;fetch();</pre><h3>2. get_magic_quotes_gpc() and Friends</h3><p><strong>Status:</strong> Removed in PHP 8.0<br> <strong>Why it’s bad:</strong> Magic quotes were always a weird band-aid on a bigger problem (input sanitization).</p><p><strong>What to use:</strong></p><ul><li>Always disable magic quotes in your server config.</li><li>Sanitize using filter_input() or prepared SQL queries.</li><li>If you <em>must</em> escape manually (please don’t), use mysqli_real_escape_string().</li></ul><h3>3. mcrypt_* Encryption</h3><p><strong>Status:</strong> Out as of PHP 7.2, fully removed in PHP 8+<br> <strong>Why it’s bad:</strong> Weak ciphers, bad IV handling, insecure by today’s standards.</p><p><strong>What to use:</strong></p><ul><li><strong>Sodium</strong> — Modern, secure, simple. Included by default since PHP 7.2.</li><li><strong>OpenSSL</strong> — For fine-grained control over algorithms.</li></ul><pre>// ✅ Using Sodium (for authenticated symmetric encryption)<br>$encrypted = sodium_crypto_secretbox($message, $nonce, $key);</pre><h3>4. money_format() — Retired</h3><p><strong>Status:</strong> Removed in PHP 8.0<br> <strong>Why it’s bad:</strong> Locale-dependent, non-portable, and non-Unicode-safe.</p><p><strong>What to use:</strong><br> Use NumberFormatter from the Intl extension. It’s smart, safe, and multi-locale.</p><pre>$fmt = new NumberFormatter(&#39;en_US&#39;, NumberFormatter::CURRENCY);<br>echo $fmt-&gt;formatCurrency(1234.5, &#39;USD&#39;); // $1,234.50</pre><h3>5. rand(), mt_rand(), lcg_value() — Weak RNGs</h3><p><strong>Status:</strong> Still there, but deprecated in spirit.<br> <strong>Why it’s bad:</strong> Not cryptographically secure.</p><p><strong>What to use (PHP 8.2+):</strong></p><ul><li><strong>random_int()</strong>, <strong>random_bytes()</strong> – Safe defaults.</li><li><strong>Random\Randomizer</strong> – For when you want complete control.</li></ul><pre>$random = random_int(1000, 9999); // Secure 4-digit PIN</pre><h3>6. mysqli_ping(), mysqli_kill(), mysqli_refresh()</h3><p><strong>Status:</strong> Deprecated in PHP 8.4, will vanish in 9.0<br> <strong>Why it’s bad:</strong> Rarely used, and better handled differently now.</p><p><strong>What to use instead:</strong></p><ul><li>Handle DB disconnects with exceptions and retry logic.</li><li>Issue raw SQL for KILL or FLUSH commands directly via query().</li></ul><h3>7. ++ on Strings — That’s Over</h3><p><strong>Status:</strong> Soft-deprecated in PHP 8.3<br> <strong>Why it’s bad:</strong> Silently changes string values; hard to reason about.</p><p><strong>What to use:</strong><br> New str_increment() and str_decrement() functions bring clarity.</p><pre>// ❌ Confusing<br>$id = &#39;AZ&#39;;<br>$id++; // becomes &#39;BA&#39; — magic?<br><br>// ✅ Clear<br>$id = str_increment(&#39;AZ&#39;); // BA</pre><h3>Why Bother?</h3><p>Refactoring out these old functions isn’t just about cleaning up warnings — it’s about writing future-proof, stable code.</p><h3>Here’s what you gain:</h3><ul><li><strong>Security</strong>: Prepared statements, modern encryption, secure randomness.</li><li><strong>Performance</strong>: Native support for server-side cursors, faster regex.</li><li><strong>Portability</strong>: Future-ready for PHP 9.0 (and beyond).</li><li><strong>Readability</strong>: Your teammates in 2030 won’t curse your 2010 code.</li></ul><p>If you’re working with a massive legacy codebase, take baby steps:</p><ul><li>Run static analysis tools like <strong>PHPCompatibility</strong> or <strong>SonarQube</strong></li><li>Turn on <strong>E_ALL</strong> error reporting in dev</li><li>Upgrade incrementally, but steadily</li></ul><h3>Final Tip</h3><p>Modernizing PHP isn’t optional anymore. If you’re serious about security, maintainability, and performance — this is your moment.</p><p>Happy refactoring! 💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f88c70bd63e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Immutable Types in PHP]]></title>
            <link>https://medium.com/@idabdasis/mastering-immutable-types-in-php-2646ef48c656?source=rss-738054c1cda2------2</link>
            <guid isPermaLink="false">https://medium.com/p/2646ef48c656</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Abd. Asis]]></dc:creator>
            <pubDate>Sun, 27 Apr 2025 14:28:13 GMT</pubDate>
            <atom:updated>2025-04-27T14:28:13.652Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Immutable Types in PHP</h3><h3>Understanding Immutable Types</h3><p>In PHP, an immutable type refers to an object whose internal state cannot be altered after it is instantiated. This practice ensures greater stability, reduces unexpected bugs, and makes applications significantly easier to maintain, especially as complexity grows.</p><h3>Key Advantages of Immutability</h3><h3>Consistent State</h3><p>Immutable objects guarantee that once data is set, it remains the same, simplifying both reasoning and debugging.</p><h3>Safe Concurrency</h3><p>With immutability, applications that rely on concurrent operations can avoid typical pitfalls like race conditions without the need for locks.</p><h3>Efficient Caching</h3><p>Since immutable data doesn’t change, caching these objects becomes straightforward and risk-free, improving overall performance.</p><h3>Fewer Unexpected Behaviors</h3><p>Reducing side-effects means the codebase becomes clearer and more predictable, leading to fewer hidden bugs.</p><h3>Comparing Mutable and Immutable Patterns</h3><pre>// Mutable approach<br>$user = new User();<br>$user-&gt;setName(&#39;John&#39;);<br>$user-&gt;setName(&#39;Doe&#39;); // Modifies the original object</pre><pre>// Immutable approach<br>$user = new User(&#39;John&#39;);<br>$newUser = $user-&gt;withName(&#39;Doe&#39;); // Produces a new instance</pre><p>Mutable objects expose the risk of accidental changes, while immutable patterns favor safe, controlled data flow.</p><h3>Best Practices for Building Immutable Objects</h3><h3>Use Private and Readonly Properties</h3><p>Starting from PHP 8.1, properties can be declared readonly to enforce immutability:</p><pre>class User<br>{<br>    public readonly string $name;<br>    public readonly string $email;</pre><pre>    public function __construct(string $name, string $email)<br>    {<br>        $this-&gt;name = $name;<br>        $this-&gt;email = $email;<br>    }<br>}</pre><h3>Eliminate Setters</h3><p>Avoid providing setters that mutate object state. Instead, offer methods that clone the object with altered values:</p><pre>public function withEmail(string $email): self<br>{<br>    return new self($this-&gt;name, $email);<br>}</pre><h3>Practical Example: A Money Value Object</h3><pre>final class Money<br>{<br>    public readonly int $amount;<br>    public readonly string $currency;</pre><pre>    public function __construct(int $amount, string $currency)<br>    {<br>        $this-&gt;amount = $amount;<br>        $this-&gt;currency = $currency;<br>    }</pre><pre>    public function add(Money $other): Money<br>    {<br>        if ($this-&gt;currency !== $other-&gt;currency) {<br>            throw new \InvalidArgumentException(&quot;Currency mismatch.&quot;);<br>        }</pre><pre>        return new Money($this-&gt;amount + $other-&gt;amount, $this-&gt;currency);<br>    }<br>}</pre><p>This ensures that money operations are safe, consistent, and traceable without the risk of altering existing objects.</p><h3>Common Mistakes to Avoid</h3><ul><li><strong>Partial Immutability</strong>: Ensure the entire object is immutable, not just selected fields</li><li><strong>Hidden Mutations</strong>: Be cautious when injecting mutable dependencies into otherwise immutable objects.</li><li><strong>Misusing Immutability</strong>: Don’t force immutability where it doesn’t fit naturally, especially if it complicates the design.</li></ul><h3>How Immutability Simplifies Testing</h3><p>Immutable structures make testing highly predictable. Tests no longer need to guard against hidden state changes, allowing clean and repeatable scenarios.</p><p>Example PHPUnit test:</p><pre>public function testAddingMoney(): void<br>{<br>    $first = new Money(100, &#39;USD&#39;);<br>    $second = new Money(50, &#39;USD&#39;);<br>    <br>    $total = $first-&gt;add($second);</pre><pre>    $this-&gt;assertEquals(150, $total-&gt;amount);<br>    $this-&gt;assertEquals(&#39;USD&#39;, $total-&gt;currency);<br>}</pre><h3>Handling Serialization</h3><p>When serializing immutable objects, serialize the public data and reconstruct using the constructor:</p><pre>$json = json_encode([&#39;amount&#39; =&gt; $money-&gt;amount, &#39;currency&#39; =&gt; $money-&gt;currency]);<br>$data = json_decode($json, true);</pre><pre>$newMoney = new Money($data[&#39;amount&#39;], $data[&#39;currency&#39;]);</pre><h3>Libraries That Embrace Immutability</h3><ul><li><strong>ramsey/uuid</strong>: Immutable UUID handling</li><li><strong>league/uri</strong>: Managing URIs immutably</li><li><strong>moneyphp/money</strong>: Comprehensive monetary value object</li></ul><h3>Performance Notes</h3><p>While immutability might cause a slight increase in memory usage due to object copying, it rarely becomes a bottleneck unless proven by profiling. Techniques like object pooling or flyweight patterns can help when necessary.</p><h3>Security Benefits</h3><p>Immutable objects inherently offer better security by preventing unauthorized data manipulation and ensuring that data remains tamper-proof during execution.</p><h3>Integrating Immutability with ORM Systems</h3><p>In Doctrine, you can define embeddable immutable value objects easily:</p><pre>/** @ORM\Embeddable */<br>class Money<br>{<br>    /** @ORM\Column(type=&quot;integer&quot;) */<br>    private int $amount;</pre><pre>    /** @ORM\Column(type=&quot;string&quot;) */<br>    private string $currency;</pre><pre>    public function __construct(int $amount, string $currency)<br>    {<br>        $this-&gt;amount = $amount;<br>        $this-&gt;currency = $currency;<br>    }<br>}</pre><p>Laravel’s Eloquent also supports casting attributes to custom immutable classes:</p><pre>protected $casts = [<br>    &#39;money&#39; =&gt; MoneyCast::class,<br>];</pre><h3>Usage of Immutable Objects in PHP Frameworks</h3><h3>Symfony</h3><p>Symfony heavily relies on immutable value objects in areas like HTTP requests, configurations, and service definitions, promoting safer and cleaner code.</p><p>Example:</p><pre>$request = Request::createFromGlobals();<br>$modifiedRequest = $request-&gt;duplicate([&#39;user&#39; =&gt; &#39;admin&#39;]);</pre><h3>Laravel</h3><p>In Laravel, collections, middleware, and several service operations take advantage of immutability principles to ensure reliable and bug-free behavior.</p><p>Example:</p><pre>$collection = collect([1, 2, 3]);<br>$newCollection = $collection-&gt;merge([4]);</pre><p>By adopting immutable types, developers can build PHP applications that are not only more reliable and easier to maintain but also better equipped to scale with confidence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2646ef48c656" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Proyek Open-Source Besar yang Dibangun dengan Laravel]]></title>
            <link>https://medium.com/@idabdasis/10-proyek-open-source-besar-yang-dibangun-dengan-laravel-9a1f4b49b3ca?source=rss-738054c1cda2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a1f4b49b3ca</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Abd. Asis]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 04:20:45 GMT</pubDate>
            <atom:updated>2024-08-12T04:20:45.876Z</atom:updated>
            <content:encoded><![CDATA[<p>Laravel telah menjadi salah satu framework PHP yang sangat populer. Tetapi, apakah ada perusahaan besar yang benar-benar menggunakannya? Atau proyek besar yang dibangun dengan Laravel? Jawabannya adalah ya! Meskipun banyak perusahaan besar tidak bisa secara terbuka menyebutkan detailnya karena aturan korporat dan NDA, kita masih memiliki akses ke berbagai proyek open-source yang besar di GitHub yang dibangun dengan Laravel.</p><p>Berikut ini adalah 10 proyek open-source besar yang dibangun dengan Laravel:</p><h3>1. <a href="https://github.com/monicahq/monica">Monica</a></h3><p><strong>Personal CRM untuk Mengingat Segala Hal tentang Teman, Keluarga, dan Hubungan Bisnis</strong></p><p>Proyek Monica menggunakan Laravel 11 terbaru dengan starter kit Jetstream Inertia stack. Selain itu, proyek ini juga menggunakan Pint sebagai perbaikan gaya kode dan larastan untuk analisis kode. Struktur proyek ini menggunakan DDD (Domain Driven Design) dengan kelas layanan.</p><h3>2. <a href="https://github.com/koel/koel">Koel</a></h3><p><strong>Server Streaming Musik Pribadi yang Berfungsi</strong></p><p>Proyek Koel dibangun dengan Laravel 10 dan menggunakan laravel/UI sebagai starter kit, serta Socialite, Scout, dan Sanctum dari ekosistem resmi Laravel. Struktur kode proyek ini menggunakan pola MVC tradisional.</p><h3>3. <a href="https://github.com/InvoiceShelf/InvoiceShelf">InvoiceShelf</a></h3><p><strong>Solusi Invoicing Open Source untuk Individu dan Bisnis</strong></p><p>InvoiceShelf adalah fork dari proyek open-source populer Crater. Proyek ini menggunakan Laravel 10 dengan starter kit Laravel/UI, Pint sebagai perbaikan gaya kode, dan Pest sebagai framework pengujian. Struktur kode menggunakan pola MVC tradisional.</p><h3>4. <a href="https://github.com/BookStackApp/BookStack">BookStack</a></h3><p><strong>Platform untuk Membuat Konten Dokumentasi/Wiki</strong></p><p>BookStack dibangun dengan Laravel 10 dan menggunakan Socialite dari ekosistem resmi Laravel. Proyek ini dirancang untuk memudahkan pembuatan dan pengelolaan dokumentasi.</p><h3>5. <a href="https://github.com/akaunting/akaunting">Akaunting</a></h3><p><strong>Perangkat Lunak Akuntansi Online</strong></p><p>Akaunting menggunakan Laravel 10 dengan Laravel/UI sebagai starter kit. Proyek ini juga menggunakan Pint sebagai perbaikan gaya kode, Pest untuk pengujian, dan Livewire. Struktur kode proyek ini mengikuti pola MVC tradisional.</p><h3>6. <a href="https://github.com/pterodactyl/panel">Pterodactyl</a></h3><p><strong>Panel Manajemen Server Game Open Source</strong></p><p>Pterodactyl adalah panel manajemen server game yang dibangun dengan PHP, React, dan Go. Proyek ini menggunakan Laravel 10 dengan Laravel/UI sebagai starter kit, serta Pint dan Pest untuk menjaga kualitas kode. Struktur kode mengikuti pola MVC tradisional.</p><h3>7. <a href="https://github.com/krayin/laravel-crm">Krayin Laravel CRM</a></h3><p><strong>Solusi CRM Laravel Gratis untuk Manajemen Siklus Hidup Pelanggan</strong></p><p>Krayin Laravel CRM dibangun dengan Laravel 10 dan menggunakan Laravel/UI sebagai starter kit. Struktur kode proyek ini menggunakan pola modul atau paket.</p><h3>8. <a href="https://github.com/Blair2004/NexoPOS">NexoPOS</a></h3><p><strong>Sistem Point Of Sale (POS) Berbasis Web</strong></p><p>NexoPOS dibangun dengan Laravel 11 dan menggunakan Reverb serta Telescope dari ekosistem Laravel. Proyek ini juga menggunakan Pint untuk menjaga kualitas kode dan mengikuti pola MVC tradisional dalam struktur kode.</p><h3>9. <a href="https://github.com/firefly-iii/firefly-iii">Firefly III</a></h3><p><strong>Manajer Keuangan Pribadi</strong></p><p>Firefly III menggunakan Laravel 11 dengan Laravel/UI sebagai starter kit dan Passport dari ekosistem Laravel. Struktur kode mengikuti pola MVC tradisional.</p><h3>10. <a href="https://github.com/coollabsio/coolify">Coolify</a></h3><p><strong>Alternatif Open-Source dan Self-Hostable untuk Heroku/Netlify/Vercel</strong></p><p>Coolify dibangun dengan Laravel 11 menggunakan Laravel/UI sebagai starter kit, serta Fortify, Horizon, Prompts, dan Socialite dari ekosistem Laravel. Proyek ini juga menggunakan Livewire secara intensif. Struktur kode mengikuti pola MVC tradisional dengan pola aksi.</p><p>Proyek-proyek ini menunjukkan betapa kuat dan fleksibelnya Laravel dalam menangani berbagai jenis aplikasi, dari CRM hingga manajemen keuangan dan streaming musik. Laravel terus menjadi pilihan utama bagi pengembang yang mencari framework PHP yang andal dan efisien.</p><p>Apakah kamu sudah pernah mencoba salah satu dari 10 aplikasi diatas, berikan komentarnya ya.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a1f4b49b3ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PHP 8.4: Pembaruan Terbaru untuk Pengembang]]></title>
            <link>https://medium.com/@idabdasis/php-8-4-pembaruan-terbaru-untuk-pengembang-7ea1e4c4f404?source=rss-738054c1cda2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ea1e4c4f404</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Abd. Asis]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 04:16:09 GMT</pubDate>
            <atom:updated>2024-08-12T04:16:09.488Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pendahuluan</h3><p>PHP 8.4 hadir dengan sejumlah fitur baru dan peningkatan yang menarik bagi para pengembang. Artikel ini akan membahas semua hal yang perlu Kamu ketahui tentang PHP 8.4 dan bagaimana pembaruan ini dapat meningkatkan proses pengembangan Kamu.</p><h3>Jadwal Rilis</h3><p>PHP 8.4 dijadwalkan rilis resmi pada 21 November 2024. Sebelum rilis ini, akan ada tahap pra-rilis berupa enam bulan Alphas, Betas, dan Release Candidates. Tahap ini bertujuan untuk memastikan rilis yang stabil dan andal.</p><h3>Fungsi Pencarian Array Baru</h3><p>Salah satu inovasi paling menonjol di PHP 8.4 adalah diperkenalkannya fungsi pencarian array baru, seperti:</p><ul><li>array_find()</li><li>array_find_key()</li><li>array_any()</li><li>array_all()</li></ul><p>Fungsi-fungsi ini mempermudah tugas-tugas umum saat bekerja dengan array. Peningkatan ini tentu akan mempercepat dan menyederhanakan proses pengembangan.</p><h3>PHP Property Hooks</h3><p>Property hooks adalah fitur baru yang terinspirasi dari bahasa pemrograman seperti Kotlin, C#, dan Swift. Fitur ini memberikan cara yang lebih halus untuk mengelola perubahan dan akses properti. Sebagai contoh:</p><pre>class User implements Named<br>{<br>    private bool $isModified = false;<br>    <br>    public function __construct(<br>        private string $first,<br>        private string $last<br>    ) {}<br>    <br>    public string $fullName {<br>        // Override aksi &quot;read&quot; dengan logika tertentu.<br>        get =&gt; $this-&gt;first . &quot; &quot; . $this-&gt;last;<br>    <br>        // Override aksi &quot;write&quot; dengan logika tertentu.<br>        set {<br>            [$this-&gt;first, $this-&gt;last] = explode(&#39; &#39;, $value, 2);<br>            $this-&gt;isModified = true;<br>        }<br>    }<br>}</pre><p>Property hooks ini menyederhanakan kode Kamu dengan menghilangkan kode boilerplate untuk getter dan setter properti, sehingga mempermudah pemeliharaan kode.</p><h3>Instansiasi Kelas Tanpa Tanda Kurung</h3><p>PHP 8.4 memperkenalkan perubahan sintaks yang memungkinkan Kamu menginstansiasi kelas dan menggunakan metodenya tanpa perlu tanda kurung tambahan. Ini membuat PHP lebih mirip dengan bahasa berbasis C lainnya seperti TypeScript, Java, dan C#.</p><pre>// Sebelum PHP 8.4: Diperlukan tanda kurung<br>$request = (new Request())-&gt;withMethod(&#39;GET&#39;)-&gt;withUri(&#39;/hello-world&#39;);<br><br>// PHP 8.4: Tidak perlu tanda kurung tambahan<br>$request = new Request()-&gt;withMethod(&#39;GET&#39;)-&gt;withUri(&#39;/hello-world&#39;);php</pre><p>Perubahan ini meningkatkan keterbacaan kode dan mengurangi kemungkinan terjadinya kesalahan.</p><h3>Membuat DateTime dari Unix Timestamp</h3><p>Membuat instans DateTime dari Unix timestamp menjadi lebih mudah di PHP 8.4 dengan adanya metode baru createFromTimestamp(). Metode ini mendukung Unix timestamp standar serta timestamp dengan mikrodetik.</p><pre>$dt = DateTimeImmutable::createFromTimestamp(1718337072);<br>$dt-&gt;format(&#39;Y-m-d&#39;);<br>// 2024-06-14<br><br>$dt = DateTimeImmutable::createFromTimestamp(1718337072.432);<br>$dt-&gt;format(&#39;Y-m-d h:i:s.u&#39;);<br>// 2024-06-14 03:51:12.432000</pre><p>Sebelumnya, pengembang menggunakan metode createFromFormat() yang kurang intuitif. Dengan metode baru ini, penanganan tanggal dan waktu di PHP menjadi lebih sederhana.</p><h3>Fungsi mb_ Baru</h3><p>PHP 8.4 memperluas dukungan string multi-byte dengan memperkenalkan varian mb_ untuk beberapa fungsi string umum:</p><ul><li>array_find()</li><li>array_find_key()</li><li>array_any()</li><li>array_all()</li></ul><p>Fungsi-fungsi ini mempertahankan argumen yang sama seperti rekan-rekan non-multi-byte mereka, sehingga memberikan dukungan yang lebih baik untuk string multi-byte.</p><p>Tetap ikuti perkembangan terbaru seiring mendekatnya rilis resmi PHP 8.4. Fitur-fitur baru ini menjanjikan peningkatan pengalaman pengembangan, membuat PHP semakin kuat dan efisien.</p><p>Terimakasih sudah membaca sampai, selamat mencoba dan happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ea1e4c4f404" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mengenal Sejarah Komputer]]></title>
            <link>https://medium.com/@idabdasis/mengenal-sejarah-komputer-14f40e7efc9e?source=rss-738054c1cda2------2</link>
            <guid isPermaLink="false">https://medium.com/p/14f40e7efc9e</guid>
            <category><![CDATA[komputer]]></category>
            <category><![CDATA[teknologi]]></category>
            <dc:creator><![CDATA[Abd. Asis]]></dc:creator>
            <pubDate>Fri, 13 Jan 2023 03:45:08 GMT</pubDate>
            <atom:updated>2023-01-13T03:45:08.569Z</atom:updated>
            <content:encoded><![CDATA[<p>Komputer adalah alat yang tak terpisahkan dari kehidupan kita sehari-hari. Dari mengetik hingga berkomunikasi, dari belajar hingga bermain, komputer membantu kita dalam berbagai hal. Namun, tahukah kita sejarah perkembangan komputer dan komponen-komponennya? Atau bagaimana jenis-jenis komputer yang ada dan fungsinya?</p><p>Pada awalnya, komputer dikenal dengan sebutan “abacus” yang digunakan untuk menghitung. Namun, seiring perkembangan teknologi, komputer mulai mengalami perubahan yang signifikan. Pada tahun 1822, Charles Babbage menciptakan komputer mekanis yang dikenal dengan sebutan “Analytical Engine”. Namun, komputer ini tidak pernah dibuat karena keterbatasan teknologi saat itu.</p><p>Setelah itu, pada tahun 1941, komputer elektronik pertama dikembangkan oleh John Atanasoff dan Clifford Berry. Komputer ini dikenal dengan sebutan “Atanasoff-Berry Computer” (ABC) dan digunakan untuk menyelesaikan persamaan matematika. Kemudian, pada tahun 1946, ENIAC (Electronic Numerical Integrator and Computer) dikembangkan oleh John W. Mauchly dan J. Presper Eckert. ENIAC dikenal sebagai komputer elektronik pertama yang digunakan untuk keperluan militer.</p><p>Kemudian, pada tahun 1951, UNIVAC (UNIVersal Automatic Computer) dikembangkan oleh Mauchly dan Eckert. UNIVAC menjadi komputer komersial pertama yang digunakan untuk keperluan bisnis. Pada tahun 1964, IBM mengeluarkan komputer System/360 yang dapat digunakan oleh berbagai jenis bisnis. Ini menjadi awal dari perkembangan komputer generasi kedua.</p><p>Komputer generasi ketiga dikembangkan pada tahun 1964–1971, yang ditandai dengan munculnya komputer mini dan mikro. Kemudian, pada tahun 1981, IBM mengeluarkan komputer personal (PC) yang dapat digunakan oleh individu. Ini menandai awal dari perkembangan komputer generasi keempat. Saat ini, komputer generasi kelima dikembangkan dengan fokus pada Artificial Intelligence (AI) dan komputasi kuantum.</p><p>Komputer terdiri dari dua komponen utama, yaitu hardware dan software. Hardware adalah bagian fisik dari komputer seperti processor, memory, hard disk, dan lain-lain. Sedangkan software adalah programatau sistem yang digunakan untuk mengontrol hardware dan melakukan tugas-tugas tertentu. Software terdiri dari sistem operasi, aplikasi, dan perangkat lunak pendukung lainnya.</p><p>Ada berbagai jenis komputer yang tersedia saat ini, mulai dari komputer desktop, laptop, tablet, server, hingga mainframe. Komputer desktop adalah jenis komputer yang digunakan di rumah atau kantor, dengan ukuran yang lebih besar dibandingkan dengan laptop. Komputer laptop adalah jenis komputer yang dapat digunakan di mana saja, dengan ukuran yang lebih kecil dan portabilitas yang lebih tinggi. Komputer tablet adalah jenis komputer yang digunakan dengan sentuhan jari, sering digunakan untuk aktivitas hiburan dan produktivitas ringan. Komputer server adalah jenis komputer yang digunakan untuk menyimpan dan membagikan data kepada beberapa komputer lain. Sedangkan, komputer mainframe adalah jenis komputer yang digunakan untuk tugas-tugas komputasi yang besar dan kompleks.</p><p>Setiap jenis komputer memiliki fungsinya masing-masing. Komputer dapat digunakan untuk pemrosesan data, komunikasi, penyimpanan data, pembelajaran, hingga entertainment. Pemrosesan data meliputi tugas-tugas seperti menghitung, menganalisis, dan menyimpan data. Komunikasi meliputi tugas-tugas seperti email, chatting, dan video call. Penyimpanan data meliputi tugas-tugas seperti menyimpan file, foto, dan video. Pembelajaran meliputi tugas-tugas seperti mengakses sumber belajar online, mengerjakan tugas, dan mencari informasi. Entertainment meliputi tugas-tugas seperti bermain game, menonton video, dan mendengarkan musik.</p><p>Perkembangan teknologi komputer juga tidak dapat diabaikan. Kecepatan komputer yang semakin cepat, kapasitas penyimpanan yang semakin besar, konektivitas yang semakin luas, serta keamanan yang semakin ketat, membuat komputer semakin canggih dan bermanfaat bagi kita. Namun, perkembangan komputer juga membawa implikasi sosial, baik positif maupun negatif. Pekerjaan, pendidikan, keamanan, privasi, hingga kesehatan, semua terpengaruh oleh perkembangan komputer.</p><p>Secara keseluruhan, komputer telah menjadi bagian integral dari kehidupan kita sehari-hari. Sejarah perkembangan komputer dari abacus hingga komputer canggih saat ini menunjukkan betapa cepatnya teknologi berkembang. Komponen-komponen komputer seperti hardware dan software, serta berbagai jenis komputer yang tersedia, menunjukkan betapa canggihnya teknologi komputer saat ini.</p><p>Fungsi komputer yang luas, mulai dari pemrosesan data hingga entertainment, menunjukkan betapa bermanfaatnya komputer bagi kehidupan kita. Namun, perkembangan teknologi komputer juga membawa implikasi sosial yang harus diperhatikan. Namun perkembangan teknologi komputer tidak akan berhenti di sini, dan kita harus terus mengikuti perkembangan komputer di masa depan dan mengejar kemajuan teknologi.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14f40e7efc9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>