Tuesday, December 20, 2022

SOLID DESIGN PRINCIPLE IN LARAVEL

 

  1. Single Responsibility Principle (SRP): In Laravel, you can use controllers to handle HTTP requests and return responses, while keeping the business logic in separate classes (e.g. services, models). This way, the controller has a single responsibility (handling HTTP requests and returning responses) and the business logic is separated into its own classes, which can be changed independently.

  2. Open/Closed Principle (OCP): In Laravel, you can use interfaces and contracts to define the methods that a class should implement. This allows you to create multiple implementations of the same interface and easily switch between them without changing the code of the class that depends on the interface.

  3. Liskov Substitution Principle (LSP): In Laravel, you can use inheritance and polymorphism to create a hierarchy of classes. For example, you could create a base Model class that defines the basic functionality of a model, and then create multiple subclasses that extend the Model class and override or add additional methods as needed.

  4. Interface Segregation Principle (ISP): In Laravel, you can use interfaces and contracts to specify only the methods that a class needs to implement. This helps to avoid unnecessary dependencies and ensures that a class only has to implement the methods that it needs.

  5. Dependency Inversion Principle (DIP): In Laravel, you can use dependency injection to decouple classes from their dependencies. This allows you to change the implementation of a dependency without changing the code of the class that depends on it, and makes it easier to test and maintain your code.

These are just a few examples of how the SOLID principles can be applied in Laravel. It's important to keep these principles in mind when designing and building applications with Laravel or any other framework to create more maintainable, scalable, and flexible code.

Tuesday, December 13, 2022

Enable SSL using certbot

 

$ sudo snap install --classic certbot


$ sudo certbot --apache -d hydrotek.solutions -d www.hydrotek.solutions

$ systemctl  restart apache2

To test auto matic renewal setup or not:

sudo certbot renew --dry-run

 

 ---------------------------------------------------

If this error shows in ubuntu:

Saving debug log to /var/log/letsencrypt/letsencrypt.log The requested apache plugin does not appear to be installed

sudo apt-get update
sudo apt-get install python3-certbot-apache

sudo certbot --apache
systemctl restart apache2