loading...

Laravel Design Patterns

github logo ・1 min read

Hello,

I am new to design patterns and would like to implement it to own project. I have the following application structure.

app
  -- Http
    -- Controllers
       ProductController.php
  -- Models
     Product
  -- Repositories
      -- Contracts
         ProductInterface.php
     ProductRepository.php

I need your help to understand with the following.
I want to make my codes extendable like what I have to do If I want to use the Cache for my queries or want to use the Redis?

ProductInterface.php

interface ProductInterface
{
    ...

    public function find($id);

    ...
}

ProductRepository.php

class ProductRepository implements ProductInterface
{
   ...

   public function find($id)
   {
      return $this->product->find($id);
   }

   ...
}

Any example is must appreciated.

twitter logo DISCUSS (1)
Classic DEV Post from Jun 1 '19

Demystifying Open Source Contributions

Jogesh profile image

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️