Traits use in laravel/lumen for standard response

Traits are a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. The semantics of the combination of Traits and classes is defined in a way which reduces complexity, and avoids the typical problems associated with multiple inheritance and Mixins.

Arrays ans Slice in Golang

Arrays are one of the most popular data structures for two reasons: arrays are simple and
easy to understand and they are very versatile and can store many different kinds of data.
You can declare an array that stores four integers as follows:


Task Scheduling in Laravel/Lumen

The Laravel framework allows you to set up scheduled tasks so that you don't have to worry about setting them up at the system level. You can get rid of that complex cron syntax while setting up scheduled tasks since Laravel allows you to define them in a user-friendly way.

Here’s a text representation that should clarify how cron works

Laravel - Lock wait timeout exceeded

Problem description:
I have a transaction in my code ,if an error occurs in executing in this transactions that doesn't trigger commit or rollback,
then the database is locked and any subsequent attempts to access the database results in this:

Transactions with eloquent in laravel

You may use the transaction method on the DB facade to run a set of operations within a database transaction. If an exception is thrown within the transaction Closure, the transaction will automatically be rolled back. If the Closure executes successfully, the transaction will automatically be committed. You don't need to worry about manually rolling back or committing while using the transaction method:

Implementing a queue

if we define an interface for a queue, it will look like this:

Implementing a stack using PHP array

we will create an interface for the stack so that we can use it in different implementations, and can
ensure that all implementations have some similarity to each other. Let us write the simple interface for
the stack:

Use the Repository Design pattern to refactor app's controller

First , we create a RepositoryInterface as a contract that defines the methods a class MUST have defined.

Run commands to dispatch a event

1. Create MassiveLocalFilesParse.php under MassiveLocalFilesParse.php folder


Subscribe to Front page feed