7 DNS Services to Protect Your Family and Network with Minimum Setup

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2021/09/quad9.jpg

DNS services come in many different forms; some focus on improving loading times, whereas others are centered on privacy and online safety. As such, they are an oft-overlooked part of your online security toolbox.

But which are the best DNS services for keeping your family and network safe? Let’s take a look. Here are seven security-focused DNS providers that you should check out today. They are easy to set up and start using.

1. Quad9


Quad9 is a free DNS service that focuses on security rather than speed (though the page loading speeds via the DNS are still perfectly snappy).

When you visit a site, Quad9 will check the site you are about to visit against a list of malicious hostnames in real-time. The list is provided by more than 12 of the world’s leading cybersecurity firms.

This process means any threats to your PC, mobile device, or smart home device will be blocked and cannot make it through to your network.

Quad9 is also committed to user privacy. Based out of Switzerland, it does not log any IP addresses and automatically uses encryption if your system supports it. Both IPv4 and IPv6 connections are also available.

2. Neustar UltraDNS Public


Formerly known as Verisign Public DNS, the company rebranded to Neustar UltraDNS Public in late 2020 following a buyout. Like Quad9, the service puts security and privacy at the heart of its operational ethos.

A few different plans are available, each of which offers differing levels of security.

For example, Neustar’s Unfiltered Resolution Plan will not block any specific categories. If you jump up to the Threat Protection plan, you can block malware, ransomware, spyware, and phishing attacks. If you plan to deploy Neustar UltraDNS Public in a home that you share with young children, you need to opt for the Family Secure option; it adds gambling, pornography, violence, and hate/discrimination to the list of blocked topics.

Behind the scenes, Neustar UltraDNS Public is using 30 nodes across six continents to do real-time filtering. Once again, IPv4 and IPv6 connections are available.

3. DNSFilter


DNSFilter is an AI-powered DNS security tool. It can help you block ransomware, phishing attacks, malware, botnets, and more.

It is primarily aimed at business users who want to protect their office’s network. Features include content filtering, the ability to enforce "safe search" on Google, Bing, DuckDuckGo, and Yandex, and low latency thanks to its 48 global datacenters.

The service is available on Windows, Mac, iOS, Android, and ChromeOS. It can protect your office network and any public Wi-Fi networks that you make available to on-premise guests.

DNSFilter costs $1 per user for up to 20 users.

4. OpenNIC


Of course, "protecting your family" doesn’t necessarily only refer to security threats. Online censorship is an equally severe problem.

Contrary to popular belief, it is not just a problem that affects authoritarian countries. The UK has suffered a never-ending will they/won’t they debate regarding blocked sites in certain categories, while the US has been quick to block access to many of the world’s leading cryptocurrency exchanges. And that’s before you consider more run-of-the-mill themes such as Netflix access and sporting events.

OpenNIC is the solution to many of these issues. The company prides itself on providing access to sites that your ISP has restricted and prevents an ISP from getting their hands on your DNS history.

The entire service is a non-profit organization run by volunteers, so there is no cost for using the app. You can choose from more than 30 servers to connect to. Each is shown with information such as whether logs are kept, the availability of DNS over HTTP, DNS over TLS, and more.

5. Yandex.DNS


Yandex is a well-known Russian search engine provider that is widely seen as a Google competitor. While some might wince at using a Russian DNS service, the product is surprisingly robust and will do a great job of blocking young eyes from seeing inappropriate content.

It has more than 80 servers in different cities around the world and will automatically block network access to adult sites when Family Mode is enabled.

There is also a Safe Mode that you can toggle on and off. When turned on, Yandex.DNS will block access to potentially dangerous sites and prevent you from downloading files flagged as malware, ransomware, and similar.

You can use Yandex.DNS on your devices (such as laptops and phones) as well as at the router level. If you want to protect an entire network, the router approach is the way to go.

6. AdGuard DNS


Ads are another serious issue when it comes to online safety for your family and keeping your network secure.

While networks like Google Ads do everything in their power to stop dangerous ads from displaying, there will always be times that something slips through the net. And that still doesn’t take into consideration all the other less scrupulous ad networks out there, many of which specialize in adult themes and even propagating malware and other viruses.

AdGuard aims to block ads at the DNS level. That means you can install this DNS on your home’s Wi-Fi router and block ads across the whole network. A family protection mode will also allow you to block sites that provide various forms of adult content, making this a one-size-fits-all option.

AdGuard has servers in the US, Europe, Japan, Southeast Asia, and Australia.

7. OpenDNS


The Cisco-owned OpenDNS is one of the most well-known names in the DNS sector. Available on the router and the device level, it offers pre-configured protection that will keep your family safe from adult content, viruses, malware, ransomware, and other forms of online threats.

Importantly for a DNS provider, the uptime is flawless. Indeed, it has managed a barely believable 100% uptime since 2006. More than 60,000 new malicious destinations are added to the database every day, and the network deals with 620 billion DNS requests every 24 hours.

Use a DNS Service Today and Stay Safe Online

All the services we have discussed in this article will keep you safe. For maximum protection, you should run them on your router rather than on a device-by-device basis. Doing so will ensure that your family won’t be accidentally exposed to dangerous content when using other gadgets.

MUO – Feed

Comic for September 15, 2021

https://assets.amuniversal.com/4b9229f0ee3e013975b0005056a9545d

Thank you for voting.

Hmm. Something went wrong. We will take a look as soon as we can.

Dilbert Daily Strip

I’m recording the complete Laravel documentation as video screencasts, and you can join the process of building this platform.

https://protone.media/img/header_social.jpg

I’m recording the complete Laravel documentation as video screencasts, and you can join the process of building this platform.

Today I want to share the birth of a new project with the Laravel community: Artisan School. The primary goal is to provide high-quality Laravel screencasts where I mix the Laravel documentation with real-life examples. Besides the video content, I want to create a place to discover code examples, links to resources, and additional content.

I’ve had the idea to record the complete Laravel documentation as video material for a while now. As you might know, I’m running a YouTube channel where I do live coding sessions now and then. However, due to the development of Launcher and other projects, the weekly schedule was not so weekly anymore, and I feel it’s time to take it to the next level!

Starting next week, you can expect the following:

  • The development of the Artisan School platform in public with live coding sessions
  • Screencasts based on the Laravel documentation with real-life examples
  • Screencasts for related open-source projects, like Inertia, Livewire, and other packages

I’ll upload new videos directly when they’re ready, not waiting until I produce a complete collection of videos.

Artisan School

Want to keep notified about Artisan School? I’ve created a small landing page with a sign-up form. I’ll start publishing the first videos soon, so please leave your email address to stay in the loop! There’s also a new Twitter account where I’ll post the videos as well.

Do you have ideas or suggestions for this platform? Don’t hesitate to send me a message, for example, on Twitter 🙂

Laravel News Links

Getting Started With Fedora Silverblue: A Flatpak-Only Version of Fedora Linux

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2021/09/fedora-silverblue-gnome-software-updates.png

Fedora Linux is one of the most well-known versions of the Linux operating system. This community-run Linux distribution, sponsored by Red Hat, prides itself on developing and introducing the software that eventually makes its way to other Linux distros.

Fedora Silverblue packages and uses that software in a way different from the traditional Linux desktop model, one that may become the way forward for Fedora and, possibly, other Linux distros. You can already use it today, and here’s why you might want to.

What Is Fedora Silverblue?

Fedora Silverblue is a version of Fedora Linux centered around rpm-ostree and Flatpak. In a nutshell, this provides Linux with the kind of security and app distribution seen on mobile phones and Chromebooks. To understand Fedora Silverblue, it helps to understand these two technologies first:

What Is rpm-ostree?

Instead of distributing an operating system consisting of hundreds of packages, Silverblue provides your system as a single image. When updates arrive, rather than downloading newer versions of specific packages, such as the system components and libraries that operate in the background, Silverblue provides a single newer image that contains these updates.

This comes with a few big benefits. One is stability. Your system won’t fail to boot or malfunction because a single package is missing or corrupted. Instead, your system is one big all-or-nothing image. But if a problem does arise, you can easily undo the mistake by booting using a previous image that is known to work.

What Is Flatpak?

Flatpak is a universal app format that enables you to install an app on virtually any Linux distro. This is a replacement for traditional packages such as DEB and RPM, which are not universal. A distro that uses DEB packages, such as Debian or Ubuntu, can not install RPM packages, and vice versa.

Flatpaks also come with added security benefits. Each app is a sandbox, isolated from the rest of your system. For an app to access other components, such as your files or your webcam, you must grant it permission.

Getting Started With Fedora Silverblue

Installing Fedora Silverblue works the same way as installing Fedora Workstation. You can head to the same website, getfedora.org, and scroll down until you see Silverblue, or you can go directly to the Silverblue website to download the necessary ISO.

If you’re familiar with the installer in Fedora Linux or Red Hat Enterprise Linux, then you already know what to expect in Silverblue. Newcomers will find the process comparable to installing applications on Microsoft Windows, where clicking the “Next” button often enough will eventually result in the software you want being installed.

Once you reboot into your new system, you will see a pristine GNOME desktop and the GNOME Tour app, which introduces you to the way GNOME works. At this point, you haven’t yet encountered a difference between Fedora Silverblue and Fedora Workstation, but you’re about to.

How to Install Updates


One of the first things you will need to do on your new system is install updates. You can open GNOME Software and try to view available updates, but this may or may not work. For better or worse, this is not an issue specific to Fedora Silverblue. I find GNOME Software to be an unreliable tool for displaying and installing updates on Fedora Workstation as well.

If GNOME Software works, you will see a prompt to “Restart & Update.” Unlike Fedora Workstation, you won’t need to wait, after you restart, for Fedora to install your packages. Instead, Silverblue will simply start back up using the newer system image that you’ve just downloaded.

If you’ve been using Linux long enough, GNOME Software not working may not seem like much of an issue. You may already be accustomed to installing updates through the command line. This is not because it is the only or easiest way to install updates on Linux, but because the command line often does the job faster and with maximum information presented, showing exactly what updates you’re getting.

On Fedora Workstation, you can install updates with:

sudo dnf upgrade

However, this doesn’t work in Fedora Silverblue. Instead, you will need to use the command:

rpm-ostree upgrade

Notice that in Silverblue the command does not require sudo or administrator access. On Silverblue, you don’t need elevated permissions to upgrade your system or install software.

When the upgrade completes, the terminal displays a full list of upgraded packages in the new system image and a command you can run to restart your system, which you need to do before any of the downloaded updates will take effect.

How to Install Apps on Silverblue

At the first launch, GNOME Software will seem more lightly populated than usual. That’s because Fedora Silverblue does not provide all of the apps available as RPMs in the usual Fedora repository. Silverblue instead uses a separate Fedora repository of Flatpak apps known as the Fedora Container Registry. Various GNOME apps, games, and a few key productivity apps like LibreOffice are available, but there’s much to be desired.

To get more software, you will want to head to Flathub and follow the very simple setup instructions. This will greatly expand the apps that are available in GNOME Software.

To install apps from the terminal, you simply use the flatpak install command. Unlike DNF, you do not need to know the exact name of a package. Flatpak will generally guess what you’re looking for or present you with options if the answer isn’t clear.

If a program you want isn’t available as a Flatpak, you still have the option to install RPMs, but here is where things get tricky.

For apps you intend to use often, you will probably want to append them to your system image using the rpm-ostree install command. Follow this command up with the exact name of the DNF package you wish to install. You will need to restart your computer afterward. From then on, your system image will include these apps during upgrades. To remove software, including preinstalled apps like Firefox, use the rpm-ostree override remove command.

The alternative approach is to launch apps from the command line. These apps will not appear in your app drawer, nor will their icons appear on your dock. To go this route, you will need to become familiar with Toolbox.

Working in the Terminal

Fedora Silverblue comes with a terminal, and most of the commands you come across will still work. But if you want to add or remove packages, you will need to turn to a tool called Toolbox.

Toolbox creates containers, or isolated workspaces, where you can install all the packages you want without cluttering your system.

To create a toolbox, use:

toolbox create

Then type:

toolbox enter

Now you can use DNF and install any Fedora packages you wish. When you are done, type exit to exit Toolbox.

Note, Toolbox containers are not isolated in a security sense. Each has access to your home directory and other aspects of your computer. Do not treat them as safe ways to mess with sketchy software.

Managing App Permissions


The Flatpak format does come with some protections against sketchy or compromised software. While you can see some of this when you open System Settings and navigate to Applications, to really take control you need to install a program known as Flatseal.

With Flatseal, you can block apps from gaining access to the network or limit them to only view files in a specific folder on your hard drive, for example. This program is available for any Linux distribution, but since Fedora Silverblue goes all-in on Flatpak, this means you have this level of control over the majority of apps on your system.

Is Fedora Silverblue Ready for Primetime?

Yes, there is already a community of people using Fedora Silverblue as their primary distro. Apps are stable and, for the most part, it looks just like regular Fedora Linux. Once you learn Silverblue’s quirks, you may actually even find it easier to use than a traditional Linux distro.

Fedora Silverblue isn’t alone. If you find this concept exciting, know that there are a few other Linux distros that have also embraced Flatpak for all of their apps. More could be on the way.

MUO – Feed

Skipper is a powerful visual editor for Laravel Eloquent

https://laravelnews.imgix.net/images/skipper18-FEATURED-IMAGE1-1631452140.png?ixlib=php-3.3.1

Engineers are the artists with better tools. They not only use their senses to create a masterpiece, they also use their brains, so they can achieve it smarter.

Imagine you can become a genuine Laravel engineer.

Imagine you can use a tool that allows you to:

  • Create a visual model of your project with just a few clicks
  • Generate all model and migration files from this model without typing any lines of a code
  • Change the model at any time in the future and get updated migrations at the same moment

Sounds too good to be true? Not at all. Skipper is a powerful visual editor for Laravel Eloquent that can do this all. And it brings you much more.

Benefits of Skipper Usage

  • Skipper saves you a huge amount of time.
    At any phase of project lifecycle, it doesn’t matter if you start from scratch or just edit an older project, this is what you always get – a terribly large amount of time, which you can spend in a better way.

  • Skipper decreases the demands on your coders’ skills.
    We all want to have the best employees possible. But sometimes, you cannot find them easily. Skipper reduces their lack of qualification by preventing possible mistakes they could make while coding manually. With the course by Tom H Anderson you will be able to give employment also to junior programmers.

  • It always allows you to perfectly know your model.
    You and your whole team can clearly see and understand the whole project logic and how the data will flow through the system. Last but not least, with the diagram, you can also easily explain it to your customer.

  • It allows understanding and management of the large projects easily
    Skipper can be used for applications with a few or hundreds of tables. Large projects are simply impossible to converse about without a visual model. Can you imagine joining a new project and they give you a SQL dump of the schema and say, “Learn this.” You probably don’t want to. With Skipper this will not be a problem anymore.

All right, until now we’ve been talking only about the comfort and the work that you can save. It might all sound like a nice marketing talk. So, do you wonder what Skipper really does in terms of Laravel coding? We understand that, let’s go through this.

Skipper Features

ORM-based Entity-Relationship Diagramming (not just database design)

  • Editing of all objects (entities, modules, associations and indexes) through an intuitive and easy-to-use interface.
  • In-built value advisors, validators, and assistants.
  • Regions and color management for a well-arranged model.

Export of models to abstract classes allowing Skipper to manage them

  • Export of Laravel migrations sequentially as your schema changes.
  • Exported migrations are in a standardized and ready-to-use format.
  • Migrations and abstract models are updated during each export, concrete models are exported one time and prepared for your customization

Import of existing projects

  • Smart wizard guides you step by step through the project import from the database.
  • You get a project model in just a few clicks.

Perfect tool for project documentation

  • Exported migrations, with a complete ERD, give perfect referential integrity.
  • Enables clear schema communication across the entire development team.
  • Data stored as XML files for better readability and versioning support.

Wide range of customization options

  • Support for your own templates, behaviors, custom properties, or data types.
  • Allows you to connect Skipper with other external tools.

Well documented

  • Comprehensive documentation covers every topic of Skipper usage.
  • To get into Skipper really quickly and smoothly, check the section “Course” in this article.

Support for Eloquent and other frameworks

  • Eloquent for Laravel.
  • Doctrine (1 and 2) and Propel for Symfony and Zend.
  • CakePHP and MongoDB ODM.
  • Customized and in-house frameworks.

More than 10.000 satisfied customers

  • Maybe you know some of them. Apple, eBay, Lidl, Avast, Hostwinds, SuddenLink, University of Kentucky… And this is just the tip of the iceberg.
  • Stable and well-tested software with more than 10-year history.

The course

The course Designing Entity Relationship Diagrams in Laravel, created by erd.design, teaches you how to start using Skipper in your project today with guides on importing existing projects, starting projects from scratch, exporting to models and migrations, and how to create a readable ERD.

The course was built with the cooperation of Skipper and Tom H Anderson. The course also influenced the Laravel Framework, Illuminate, with new functionality added to allow changing of DateTime schemas.

All this was done to share the beauty of development that Skipper catalyzes. With 10 years of Skipper experience, erd.design is in a unique position to teach ERDs with Skipper and, through this ever-improving course, bring better Eloquent ORM engineering to a wider audience. Use the coupon code LARAVELNEWS for and you will get 25% price reduction.

Skipper Licensing

During 14-day long evaluation period, you can try for free all Skipper features and functions.

You can buy a lifetime license for €395 ($495) which also includes all updates for a 1-year period. After that, there is an annual maintenance agreement of €139 ($169) which gives you constant access to updates for the next 1 year.

If you like Skipper and have some ideas you could share with us, we would be happy for your feedback. In exchange, we want to offer you 10% off the price for your purchase. Write to us to support@skipper.com and we will provide you with your price-cut coupon.

Laravel News

Making Movie Natural Disasters

https://theawesomer.com/photos/2021/09/making_natural_disaster_movies_t.jpg

Making Movie Natural Disasters

Link

Movies and TV shows use a mix of practical, optical, and digital visual effects to simulate natural disasters. Insider compiled behind-the-scenes footage from eight movies where VFX pros brought storms, earthquakes, tsunamis, and other acts of Mother Nature’s fury to life.

The Awesomer

Understanding the magic of Laravel macros


Using Laravel macros is a powerful way to extend default behavior of many classes in Laravel, such as Collections, Stringables and Reponses. In this article I’m going to explain how these macros work under the hood.

What are macros?

Using macros, you can extend default methods in a class. Take for example this macro:

Collection::macro('insertBetweenEach', function ($value) {
    return $this->flatMap(fn ($item) => [$item, $value])->slice(0, -1);
});

Now if you run this code:

collect([1, 2, 3])->insertBetweenEach(4)->dd();

You’ll get this output:

[1, 4, 2, 4, 3]

As you can see, it’s very simple to add macros and thus extend classes like Collection, Str, Stringable and Response. And if you would try to change the core classes in the vendor folder, you would loose all methods when updating or deploying.

The Macroable trait

All classes that offer macro-functionality, use the Illuminate\Support\Traits\Macroable trait. You can even add this to your own classes too!

The trait adds a protected property to the class, called $macros. When you register a macro using the macro() method, it will be saved in this array.

// vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php

trait Macroable
{
    protected static array $macros = [];

    public static function macro(string $name, object|callable $macro): void
    {
        static::$macros[$name] = $macro;
    }
}

Calling methods

When you call a method that does not exist on a method, PHP will check for a __call() method and runs that instead of throwing an exception. In this method Laravel will check if there is a macro registered and run that.

// vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php

trait Macroable
{
    protected static array $macros = [];

    public static function macro(string $name, object|callable $macro): void
    {
        static::$macros[$name] = $macro;
    }
    
    public function __call(string $method, array $parameters): mixed
    {
        if (!isset(static::$macros[$method])) {
            throw new BadMethodCallException(sprintf('Method %s::%s does not exist.', static::class, $method));
        }

        $macro = static::$macros[$method];

        if ($macro instanceof Closure) {
            $macro = $macro->bindTo($this, static::class);
        }

        return $macro(...$parameters);
    }
}

This method exists of four parts:

  1. It checks if the macro exists, and if not it throws an exception
  2. It finds the corresponding macro
  3. If the macro is callable (a Closure), it will bind the callback to the current class, so if the macro calls $this it works as expected
  4. It will run the macro

Static methods

When a static method is called that does not exist, PHP will execute the __callStatic() method instead of __call(). This will basically do the same thing as __call(), except not binding the callback to the current instance.

// vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php

trait Macroable
{
    protected static array $macros = [];

    public static function macro(string $name, object|callable $macro): void
    {
        static::$macros[$name] = $macro;
    }
    
    public function __call(string $method, array $parameters): mixed
    {
        if (!isset(static::$macros[$method])) {
            throw new BadMethodCallException(sprintf('Method %s::%s does not exist.', static::class, $method));
        }

        $macro = static::$macros[$method];

        if ($macro instanceof Closure) {
            $macro = $macro->bindTo($this, static::class);
        }

        return $macro(...$parameters);
    }
  
    public static function __callStatic(string $method, array $parameters): mixed
    {
        if (!static::hasMacro($method)) {
            throw new BadMethodCallException(sprintf('Method %s::%s does not exist.', static::class, $method));
        }

        $macro = static::$macros[$method];

        if ($macro instanceof Closure) {
            $macro = $macro->bindTo(null, static::class);
        }

        return $macro(...$parameters);
    }
}

Conclusion

Although Laravel macros may seem hard to understand, they are actually very simple to understand and use.

Laravel News Links

How To Automatically Apply the Laravel-PHP Coding Style (For Free)


If you work inside a team, do yourself a favor – decide on a coding style and get the entire team to use it.

Why Stick To a Standard Code Style?

Making all your teammates’ code look the same will make the codebase so much easier to review, merge and maintain:

  • it’ll be easier for you to judge only how the code works, without being distracted by how it looks;
  • you won’t have PRs bloated by striping spaces, removing spaces, converting tabs to spaces, moving parentheses on the next line… and so on; less to think about during review; fewer conflicts to fix;
  • even if you work solo – I’d argue it’s still very a good idea to do it; adopting PSR-12 in particular will make your code look the same as most well-maintained PHP projects; so when you go look at their code, it’ll actually start looking… a little more familiar; so it’ll be a little easier to learn from them;
  • plus, I bet you will adopt PSR-12 one day, so if you start now… you’ll thank yourself later on; be kind to your future self!

Which Code Style to Choose?

Fortunately, thanks to PHP-FIG, it’s easy to choose a standard to start from – PSR-12. Digging a little deeper though, the Laravel ecosystem has pretty much decided on a few rules on top of that. Personally I don’t agree with all of them… but… that’s normal. Ask 10 developers what they like and… you’ll get 10 different answers. So in this case, I found it’s better to just… stick to the Laravel standard. You don’t like X in particular, your coworker doesn’t like Y, and so on, but… you each give in a little bit, for the sake of standardization. Everybody compromises, nobody has a reason to make a fuss… it’s the fair way to go, if you ask me. But hey… you do you 😀

How Do I Automatically Enforce It?

There are quite a few ways to do this automatically:

Option 1. Use StyleCI

If you can use StyleCI, use that. This is why it exists, and it does an excellent job. When someone pushes code to the repo, StyleCI comes in and formats it, by changing their PR to match the code style. It’s simple and brilliant. In fact, we use StyleCI for all the public-source Backpack packages and it’s worked wonders. Just follow the prompts to set it up, then you can forget about it.

If your code is open-source, this is such a good option, that you don’t need to read any further!

However… if your code is closed-source (not public)… you might find your particular company/setup can’t use StyleCI. You might develop A LOT of private projects, that are not under continuous development or maintenance… so you don’t want to pay for a maintenance fee for legacy projects… we get it, we got there too. In that case, the StyleCI pricing won’t make sense for you. In that case…

Option 2. Use PHP-CS-Fixer in Your Editor/IDE

Use php-cs-fixer locally, on each developer’s computer. There are plug-ins for every major editor and IDE, so it should be easy to do. You can store a configuration file in your project root, to make sure you all enforce the same rules.

However, this does assume you can tell your developers “do this, we all need to use the same code style“. In most teams, you can. But even if they do, most developers switch editors, forget to install the plugin, so unstyled code does go through, sometimes. For that reason alone, I don’t trust this method alone. So what I prefer is to…

Option 3. Use PHP-CS-Fixer Inside a Github Action

If none of the above float your boat, there’s one super-simple solution that you can implement, then forget about. It has most of the benefits of StyleCI (it’s implemented where the code is stored, on Github) and most of the benefits of PHP-CS-Fixer (it’s free).

You can implement a Github Action. Every time code is pushed or a pull request submitted, you can run php-cs-fixer on that code and fix whatever is needed. That way, no matter what developers submit, the code will be styled according to the standard.

To be honest, this is the entire reason this article exists – so I get to document how I did this 😀 Hopefully it’ll save you some time (and future me too). Here’s how to go about it:

Step 1. Create a configuration file for PHP-CS-Fixer (.php-cs-fixer.dist.php in your root directory). Here’s the content we use for it, after digging quite a bit. Note that if you don’t have a directory mentioned at the end, you should comment them out, otherwise PHP-CS-Fixer will fail. If you have any comments/improvements on the code style, please suggest them in my gist, it’s open for improvements.

Step 2. Add .php-cs-fixer.cache to your .gitignore file.

Step 3. Add a PHP-CS-Fixer as a dev requirement: composer require --dev friendsofphp/php-cs-fixer

Step 4. Add a Github action/workflow for it, by creating a .github/workflows/format_php.yml file:

name: Apply PHP Code Style

on:
    push:
        branches:
            - 'master'
    pull_request:
        paths:
            - '**.php'

jobs:
    php-cs-fixer:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/[email protected]
              with:
                  ref: $

            - name: Install
              run: composer install

            - name: Run php-cs-fixer
              run: ./vendor/bin/php-cs-fixer fix

            - uses: stefanzweifel/[email protected]
              with:
                  commit_message: Apply php-cs-fixer changes

That should be it. Once you push code to your repo, a new commit should automatically be created, fixing the style. This works particularly well if you work with PRs, because then you squash and merge them and you won’t bloat up your git history.


I hope this will be helpful to you. If you have a better way of doing this, let me know in the comments. I know there are a lot of ways, but this is what I found to be the best for us, in Sep 2021.

Laravel News Links