Here is all articles with programming tag
PHP enums provide a clean way to represent a fixed set of possible values. When working with a backed enum, each enum case has an associated scalar value, such as a string or integer. A common situation is receiving a value from a database, API request, form, or another external source and needing to retrieve […]
In PHP, you can create a reference to a variable using the & operator. A reference means that two variables point to the same value, so changing one variable can also affect the other. Here is an example of creating reference in PHP. In the code below $b is a reference to $a, means if […]
Have you ever run chmod on a folder or file in Linux, only to open git status and see a long list of modified files, even though you didn’t change a single line of code? This is a common frustration for developers working with any project on Linux. Git is tracking file permission changes (the […]
SQL injection is one of the oldest and most dangerous security vulnerabilities in web applications. If you’re building applications with Laravel, you may wonder: Does Laravel automatically protect against SQL injection, or do I need to implement additional security measures? The short answer is yes Laravel provides strong built-in protection against SQL injection when you […]
Object-oriented programming in PHP gives developers powerful inheritance features. However, not every class is designed to be extended. That’s where the final keyword comes in. A final class explicitly tells PHP that this class cannot be inherited. It protects the class from being extended and helps preserve its intended behavior. When you declare a class […]
Starting with Laravel 12, Laravel introduced the #[CurrentUser] attribute, making it easier to access the authenticated user inside controller methods. Instead of retrieving the user manually using Request object or auth() helper, you can now ask Laravel to inject the authenticated user directly into your method. This results in cleaner, more readable controller code while […]
If you frequently start new projects, you’ve probably found yourself copying an existing project over and over again.Maybe you have a Laravel starter kit, a Node.js boilerplate, a PHP project structure, or simply a repository containing your preferred folders, configurations, and development tools. Instead of cloning a project and cleaning it up every time, GitHub […]
When working with Eloquent models in Laravel, you may have seen both of these approaches used to access model attributes: Although they may seem identical, they behave differently under the hood. Understanding the difference is especially important when creating custom accessors, mutators, casts, and model attributes. # Quick Answer The main difference is $this->columnName passes […]
When working with Laravel, performance is often a major concern. One common optimization is using bulk updates instead of loading and updating models one by one. However, there is an important behavior that many developers overlook: Laravel Observer events are not triggered when using bulk update queries. If your application relies on observers for logging, […]
Artificial Intelligence is one of the hottest topics in tech right now. Everywhere we look, we hear bold statements from AI company CEOs and tech influencers claiming that programmers will soon be replaced by AI. But how true is that? Some developers believe AI will eventually replace most programming jobs. Others completely disagree. The truth […]