Back to all funny docs

Laravel Pint: Your Chill Buddy for Code Quality! 🍻

Warning: May cause actual learning AND laughter!

Laravel Pint: Your Chill Buddy for Code Quality! 🍻

Looking to make your code as smooth as a well-shaken Margarita? Look no further than Laravel Pint! This friendly little tool is here to help you keep your code clean, organized, and ready for the spotlight. 🌟

Installation: Bringing Pint into Your Life 🚀

Adding this charming chap to your Laravel project is easier than teaching a cat to fetch – just a few simple commands, and voila! You’ll be sipping on top-shelf code quality in no time.

Running Pint: Time for a Quality Check 🕵️‍♂️

Once installed, running Pint is as easy as serving up a cold one on a hot summer day. Just fire it up with a simple command, and let him do his magic. He’ll scan your codebase, looking for any dusty corners that need some tidying up.

Configuring Pint: Tailoring the Experience 👨‍tailor

Pint is a flexible friend, easily adaptable to your specific needs and preferences. You can customize his rules, choose from presets (because who has time to create their own rulebook?), and even tell him which files or folders to ignore – we all have those secret stash directories, right?

Presets: Pick Your Flavor 🍦

Pint comes pre-loaded with a variety of presets, each designed to cater to different tastes. Whether you’re into Strict Standards or Just the Basics, there’s something for everyone!

Rules: The Code Housekeeping Guide 🧹

If the presets don’t quite fit your needs, no worries! You can create custom rules to suit your specific project or team. Pint’s rulebook is open for business – write what you want, enforce what you need.

Excluding Files / Folders: Keeping Secrets Safe 🔐

Tired of Pint snooping around in your secret files? Just tell him which areas are off-limits, and he’ll respect your privacy (well, as much as a code quality tool can, anyway).

Continuous Integration: Keeping the Party Going 💃️

Integrate Pint into your continuous integration pipeline, and he’ll become an ever-vigilant watchdog. He’ll make sure that any new code added to the project meets his high standards – because who wants a hangover from bad code?

GitHub Actions: The Perfect Pair 🍺💻

Pairing Pint with GitHub Actions is like matching a fine wine with a gourmet meal – it just works! Together, they’ll ensure that every commit to your repository results in sparkling clean code. And who knows, maybe you’ll even earn some brownie points from the boss! 🍫🎉

Ahoy there, PHP coders! Prepare to meet your new best friend: Laravel Pint - a svelte, no-nonsense PHP code stylist for minimalists who believe that less is more (and cleaner)! Built upon the mighty PHP CS Fixer by the FriendsOfPHP crew, Pint makes it ridiculously easy to keep your code as tidy and uniform as a freshly pressed suit.

Best part? It’s already included in every swanky new Laravel application you create, so no fussing with installations or configurations - just dive right into coding! And since it follows the stylishly opinionated coding standards of Laravel, your code will be as sleek and well-dressed as your favorite superhero.

But enough about the formalities - let’s get our hands dirty and start coding with this fabulous new tool in town! 🤓💃🕺

Alrighty then! Let’s get this code party started without the usual drama of software installation. You see, Laravel Pint is already a VIP guest in your Laravel framework’s latest releases – no need to send out a formal invite or anything. But for those timeless classics that refuse to dance with the times (yeah, we’re talking about you, old apps), here’s the dance card:

“Slide onto the dance floor with this snazzy command:”

composer require laravel/pint --dev

And just like that, Laravel Pint will be your new best friend at the coding bash! 🤝🎉💃

Now, if you want to run a style check on your project, you can do it with these cool moves:

./vendor/bin/pint --style=laravel

And remember, my friend, just like a well-rehearsed dance routine, good coding standards keep things running smoothly. So, let’s boogie to better code together! 🕺️💃️🎶

Alrighty then! Let’s dive into the world of Pint, your trusty code style ninja, hidden within your project’s vendor/bin directory. To get Pint to whip your code into shape, just shout out its name in the terminal:

./vendor/bin/pint

If you want Pint to work faster than a caffeinated squirrel on roller skates (experimental mode), throw it the --parallel bone:

./vendor/bin/pint --parallel

You can even tell Pint how many processes to unleash via the --max-processes option. If you don’t specify, it’ll use all the cores on your machine like a power-hungry CGI-baboon:

./vendor/bin/pint --parallel --max-processes=4

To direct Pint to specific files or folders, just point it in the right direction:

./vendor/bin/pint app/Models

./vendor/bin/pint app/Models/User.php

Pint will proudly display a list of all the files it’s corrected, like a cat showing off its freshly caught mouse. For extra detail on Pint’s changes, add the -v option:

./vendor/bin/pint -v

If you just want Pint to sniff out style errors without making any changes (like a cop writing traffic tickets), use the --test option. If it finds any errors, it’ll return a code that screams “Guilty!”:

./vendor/bin/pint --test

If you want Pint to only inspect files that have changed since a certain Git branch (useful in your CI environment), throw it the --diff=[branch] option:

./vendor/bin/pint --diff=main

To make Pint focus on files with uncommitted changes according to Git, give it the --dirty option:

./vendor/bin/pint --dirty

If you want Pint to fix any files with code style errors but also exit with an error code if any errors were fixed, throw it the --repair option:

./vendor/bin/pint --repair

And there you have it! Now your code will be cleaner than a cat after a bath, and Pint can go back to binge-watching coding tutorials on YouTube. Happy coding!

Unleashing Pint: The Magic Style Wand! 🧝‍♂️🚫💔

Alright, let’s talk ‘bout Pint, the coding style enforcer that’s as cool as a cucumber in a blender on a hot day. Now, here’s the fun part: Pint doesn’t need a tuxedo-clad butler to serve it martinis - it operates just fine without any configuration! 🎉🥳

But, if you’re one of those folks who like their coding styles tailor-made and personalized, we’ve got you covered! You can customize the presets, rules, or the folders Pint inspects by creating a pint.json file in your project’s root directory. It’s as simple as whipping up a batch of cookie dough!

{
    "preset": "laravel"
}

Don’t worry, we didn’t leave the fashionably latecomers hanging! If you’ve already got a pint.json file in some other directory that you’d rather use, no problemo! Just provide the --config option when summoning Pint:

./vendor/bin/pint --config vendor/my-company/coding-style/pint.json

Now, wasn’t that a piece of cake? 🍰🎂 Just remember, with great power comes great responsibility (and coding style consistency!). Happy Pinting! 💻🤖💖

Style Squad! 🚀

Who needs a fashion police when you’ve got Pint’s Style Squad? These stylish enforcers ensure your code is always dressed to impress, and they do it with flair! By default, our squad follows the Laravel Fashion Police’s guidelines (we call it the laravel preset), but we understand everyone has their own unique style.

To switch up the look, just drop the --preset bomb during your Pint party:

./vendor/bin/pint --preset psr12

Or, if you’re feeling extra committed, set a permanent preset in your project’s pint.json file:

{
    "preset": "psr12"
}

Our Style Squad is versatile and well-versed in various coding fashion trends, including: laravel, per, psr12, symfony, and even the minimalist empty. So, whether you’re a fan of bold colors or prefer a more understated aesthetic, we’ve got you covered! 🕶️😎

Alrighty, let’s delve into the world of Pint, your stylish code whisperer! Rules here are like a sartorial guide for your code, ensuring it doesn’t look like a hot mess at a fancy ball. These aren’t just any rules, oh no, they’re the fashion police of the programming universe!

Preset is basically a pre-packaged ensemble that suits most PHP projects. So, unless you’ve got an itch for individuality or a burning desire to stand out like a peacock at a penguin party, you can happily let presets do their thing.

But hey, if you fancy tweaking the rules to your liking, or going au naturel with the empty preset, you can! Here’s how:

{
    "preset": "laravel",
    "rules": {
        "simplified_null_return": true,  // Because who needs complexity when you can have null?
        "array_indentation": false,       // Spaces are for hippies, not our code!
        "new_with_parentheses": {
            "anonymous_class": true,     // Anonymous class? More like Anonymous Party! Let's get this function started!
            "named_class": true           // Named classes are so 20th century. Let's bring on the parentheses!
        }
    }
}

Pint isn’t a one-trick pony, no sir! It’s built upon the mighty PHP CS Fixer, which means it can whip your code into shape with any rule from its extensive wardrobe: PHP CS Fixer Configurator.

So, go ahead and let Pint work its magic! It’s your ticket to a well-dressed code party where everyone looks fabulous!

Oh, hi there, code cowboy (or code cowgirl)! Let’s talk about custom rules, shall we? You see, Laravel’s PHP CS Fixer buddy, Pint, isn’t just another Lone Ranger roaming the Wild West of your codebase. Nope, this fella’s got a secret stash of custom rules, all prefixed like a Vegas high roller with Pint/.

Now, these rules are a little more exclusive than a VIP section in a neon-lit casino – they ain’t enabled by default. But fear not, for you can give ‘em the green light right from your pint.json file!

And here’s a little gem: if you wanna play hardcore with PHP docblocks, you can use the Pint/PHPdocTypeAnnotationsOnly rule. This one’s like the code equivalent of a high-stakes poker game – only allowing type annotations in your docblocks and nudging you towards writing cleaner, more precise code.

Now that you know about custom rules, go forth and tame the wild west of your Laravel codebase with Pint’s help! Just remember: in this town, there’s no room for sloppy code – only well-structured, easy-on-the-eyes code!

Ahoy there, code pirates! Dive into the enchanted waters of Laravel land with our magical Pint rule: Pint/phpdoc_TypeAnnotationsOnly! This rule, much like a finely-tuned barber, snips away all your verbose comments and docblock prose, leaving behind only those lines adorned with the shimmering @ annotations, such as @param, @return, @var, @phpstan-type, and so on.

Here’s a glimpse of what this mermaid magic looks like:

/**
 * Get the posts for the user. [tl! remove]
 * [tl! remove]
 * @return HasMany<Post, $this>
 */
public function posts(): HasMany // Now a sleek, streamlined line of code!

Single-line comments and block comments without those enchanting @ annotations? Splash overboard, matey! This rule doesn’t suffer fools. But fear not, if there’s a specific comment you’d like to preserve, simply prefix it with @note, @warning, or @todo:

// @note This comment will be preserved, so don't walk the plank!

Want to enable this magical rule? First, make sure your ship’s pint.json file is well-equipped with:

{
    "preset": "laravel",
    "rules": {
        "Pint/phpdoc_type_annotations_only": true
    }
}

And ta-da! Your code will be as clean and shiny as a freshly minted doubloon! Oh, and don’t forget: this rule automatically skips files in the config directory, because thoseconfiguration files often rely on comments for navigation. Aye, matey, happy sailing!

Embracing the Art of Avoidance in Laravel Land! 🕺️

Welcome to the magical world of Laravel, where we dance delicately between the lines of code! By default, our friendly automaton, Pint, checks out all .php files in your project - but shies away from those nestled deep within the vendor directory. If you’ve got a hankering to keep more folders at arm’s length, fear not! You can do so using the ‘Run Away’ configuration option:

{
    "run_away": [
        "my-specific/folder"
    ]
}

Now, let’s imagine you’ve got a sneaky file that keeps causing trouble and won’t take ‘no’ for an answer. If it bears a name pattern that makes your eyes twitch, fear not! You can give it the cold shoulder using the Not_So_Friendly configuration option:

{
    "not_so_friendly": [
        "*-my-file.php"
    ]
}

And in case you’ve got a specific file that’s been overstepping its bounds and needs a firm ‘time out’, you can banish it using the Not_In_My_Project configuration option:

{
    "not_in_my_project": [
        "path/to/excluded-file.php"
    ]
}

Just remember, in this enchanted land, you can never have too many rules to keep the mischievous ones at bay! 🧞‍♂️😉

Unicorn Herding 101: Riding the CI Wave!

Ahoy, code wranglers! Welcome to the mystical land of Continuous Integration (CI) where your dreams of bug-free software come true (well, mostly). Grab your magic wand and let’s embark on this thrilling journey together!

Testing on GitHub Actions: The Magical Unicorn Rodeo

In our enchanted kingdom, GitHub Actions serve as the trusted unicorn wranglers, ensuring your code’s quality with every commit. To participate in the magical unicorn rodeo, follow these simple steps:

  1. Prepare thy environment: Configure your .github/workflows directory by creating a new YAML file (e.g., phpunit.yml). This file will instruct our unicorns on how to test your code.

  2. Summon thy unicorns: Define jobs within the YAML file, each responsible for executing a specific task, such as testing or deploying. Give them catchy names like “PHPUnit Trott” and “Deployment Breeze.”

  3. Equip thy unicorns: Instruct your unicorns on which PHP versions to use, which extensions they need, and any other necessary settings by adding env, services, and run commands within the jobs. Remember, a well-equipped unicorn is a happy unicorn!

  4. Unleash thy unicorns: Save your YAML file and GitHub will automatically run your tests whenever you push new code to your repository. If any errors or bugs rear their ugly heads, the unicorns will alert you with grace and finesse (and maybe a bit of sarcasm).

  5. Revel in thy success: With your magical unicorn rodeo set up, you can rest easy knowing that bugs will be squashed before they have a chance to wreak havoc on your project. And the best part? No more late-night emergency bug fixes! 🎉🦄🌈

Alrighty, Buckaroo Banzai! Let’s dive into the delightful world of GitHub Actions for automating your Laravel project’s style check with Laravel Pint.

First things first, you’ve gotta make sure that GitHub trusts you like a best buddy at Settings > Actions > General > Workflow permissions. Grant those “Read and write permissions” and consider it as an unspoken promise to keep the code clean and free of syntax shenanigans.

Next, create a little file called .github/workflows/lint.yml, fill it with some friendly YAML commands, and let’s get this party started!

Name: The Code-Style Sheriff

Trigger: When new code is pushed to GitHub ([push])

Jobs:
  Lint 'em Up:
    Runs on: Ubuntu's latest and greatest
    Options:
      Fail-fast: true - Let's not waste time on faulty commits, m'kay?
      Matrix:
        PHP: [8.4] - We don't do archaic languages here!

    Steps:
      1. Checkout code - Get the source code from GitHub using our secret decoder ring (actions/checkout@v5)
      2. Setup PHP - Invite PHP to the party with the help of shivammathur/setup-php@v2, making sure they bring their Pint tool along!
      3. Run Pint - Time for the style check, run "pint" and let's see if we can lick this project into shape!
      4. Commit Linted Files - Automatically commit the linted files using stefanzweifel/git-auto-commit-action@v6

Now that your GitHub Actions are in place, you can sit back and watch as your Laravel Pint ensures that all commits maintain a consistent and beautiful codebase. Just remember to thank your actions like the helpful little helpers they are! 🤖🥳🎉

Other Funny Docs

**Welcome to Laravel Land!** 🌄 # Collections 🎉🎩 # Concurrent Chaos, or How to Make Your Computer Dance Simultaneously 🕺️💃️ # Controllers: The Gladiators of the Digital Colosseum 🏆 # Database: The Magical Scroll of Infinite Data! 🧙‍♂️📖 # Eloquent: The Great Serialize-Off! 🥳🎉 # Eloquent: The Swanky Buffet of Data! 🎉🍽️ # Eloquent's Amorous Affairs: A Love Letter to Data Relations! # Hashbash 101: Laravel's Secret Sauce for Security! 🔒🎉 # Laravel's Heart Monitor 💼🕺️ # Laravel's Magical Deployment Genie: Envoy! 🧞‍♂️🎩 # Laughter Logs 😃 # Locksmith Services: Laravel's Top-Secret Spy Kit 🔑🕵️‍♂️ # The Database Dance: A Laravel Ballroom Guide 💃🏻🎉 # The Grand Ol' Setup! 🎶🥁 # The Great File Adventure! 📚 🚀 # The Great Laravel Password Adventure # The Magnificent Mongoose's Guide to Storing Data in the Land of BSON! 🦁📜 🔔📣 **Attention All Developers!** A Journey Through Laravel's File System Jungle! 🌳🔍 Ahoy there, coders and jesters alike! Brace yourself for a thrilling journey through the fantastical realm of Laravel Strings - the magic ingredient that makes your apps talk to you like a wise old sage (or a chatty parrot, if you prefer). Ahoy there, database enthusiasts! Let's embark on a fantastical journey into the heart of Laravel's mystifying seed land! Yes, you heard it right – we're talking about Database Seeding! Ahoy there, intrepid coder! Set sail for a grand adventure with Laravel's swashbuckling documentation! 🏴‍☠️ Ahoy there, Laravel sailors! Buckle up for an exhilarating journey into the realm of Eloquent API Resources. This section is chock-full of goodies that'll make your RESTful dreams come true. Let's dive right in! 🌊 Ahoy there, matey! Buckle up for a whirlwind tour of Laravel's process management! This is where the magic happens, and by "magic," we mean command line sorcery. Ahoy, mateys! Sail the Laravel seas with us as we delve into the art of mockery - not the kind that makes people laugh (although that's always a plus), but the one that helps you write better tests. Ready to plunder treasures of knowledge? Let's set sail! Alright, let's dive into the hilarious world of Laravel Licensing! 🎠🎪 Alrighty, buckle up, coding cowboy (or cowgirl)! Let's dive into the wild west of Laravel deployment where we'll tame servers, tweak configurations, and optimize for speedier draw times. But first, a quick warning: this here is more than just roping cattle, so if you ain't familiar with server requirements, Nginx, FrankenPHP, or directory permissions, best hitch a ride on the documentation horse. Anchors Aweigh! Welcome to Laravel Sail! 🚢🚀 Console Chortles: The Laugh-and-Learn Guide 🎤️ Contracts: The Sworn Code of Laravel Land! 🤝📜 Database: The Gateway to Data Nirvana 🚀🌟 Database: The Quarry Master Database: Time Machine for Your Data Eloquent: The Magic of Mutators & Casting! 🎩✨ Eloquent: The Magical Factory of Your Database Dreams! 🧚‍♂️🛠️ Eloquent: The Posh Puppy of PHP Database Frameworks! 🐶 Fancy Pants Shortcuts 🤵👗 Frontend Fun Times! 🎉🎈 HTTP Hooligans: A Survival Guide for Web Shenanigans in Laravel Land! 🤓 Laravel Cashier (Paddle): The Silicon Valley of Subscription Billing 🚀✨ Laravel Cashier: Your Buddy for Stripe Shenanigans! 💰💳 Laravel Dusk: The Web Browser Robot for Your Laravel App! 🤖 Laravel Flagship 🏳️‍🌈 Laravel Forti-Fantastic! 🎉🏰 Laravel Mix: The Magical Elixir of Your Web Application's Happiness 🍰 Laravel Octane: The Supercharged PHP Superhero! ⚡️🚀 Laravel Passport: The Magic Key to Your API Kingdom 🔑✨ Laravel Sanctum: Your Secret Weapon for API Security! 🚀🛡️ Laravel Scout: The Sherlock of Databases! 🕵️‍♂️ Laravel's AI Sidekick 🚀🤖 Laravel's AI Time Machine 🕰️🚀 Laravel's Bag O' Tricks! Laravel's Dance Floor: A Symphony of Code! 🎶🥁 Laravel's Magical Command-Line Puppeteer (MCP) ✨🎩 Laravel's Magical Domain Whisperer: Valet! 🧙‍♂️🔮 Laravel's Magical Homestead for Developers, Wizards, and Aliens! 🏡🚀 Laravel's Magical, Shiny Socialite! 🌈✨ Laravel's Shining Star: Horizon! 🚀✨ Laravel's Stargazing Gadget: Telescope! 🔭🚀 Laravel's Swanky Navigation Guide! 🕺️ Laugh, Log, Love! 🤖 logging in Laravel 🎉 Laugh, Test, Conquer: Your Laravel Guide to Fun-tastic Testing! 🥳🎉 Laughable Laravel HTTP Hilarity! 🎭💬 Laughing at the Glitches: Laravel's Error Handling Guide! 😜 Laughter and Coding: A Journey to Laravel 13.0! (From the Stables of 12.x) Let's Chat Like Never Before with Laravel Broadcasting! 🗣️🎙️ Lingo-Magic: Make Your Laravel App Speak Every Language Under the Sun! 🌍🎙️ Middleware Mayhem! 🕹️🦸‍♂️ Package Shenanigans! 🎉🥳 Redis: The Swift, Silicon Superhero of Data Storage! 🦸‍♂️🚀 Rockstar Rate Limiting 🎸🥁🎉 Service Provider Shenanigans! 🤘 Temples of Data: Laravel's Views Temple (Don't worry, no incense required) The All-Knowing, Magic Bean of PHP Land! 🪄🚀 The Art of Email in Laravel Land! 🕵️‍♂️💌 The Art of Validation: A Laravel Masterclass! 🎉🎓 The Artisan's Playground 🧛‍♂️🔩 The Dance of Responses The Gatekeeper's Handbook (But Slightly More Entertaining) The Globetrotter's Guide to Laravel Sessions The Great Escape Act: Laravel's Magic Trick with Queues! The Great Interweb Explorer: Laravel's HTTP Client The Great Laravel Journey: A Comic Adventure! 🎉🚀 The Great Laravel Soiree: An Eventful Revelry! 🎉🎊 The Incredible Journey of Email Verification! 🚀📧 The Incredible, Mysterious World of CSRF Protection! 🦹‍♂️🔒 The Joyful Symphony of Asset Bundling: Vite Edition! 🎶 The Laravel Play-Doh Kit: Your Gateway to Fun and Fancy Web Development! 🎨🌐 The Magic Show of Laravel Lifecycle 🎩✨ The Quest for Knowledge: A Laravel Adventure! 📚🚀 The Time Travelling Task Manager (TTTM) The Wild West of Web Navigation: Laravel's Routing! 🤠🎠 Time Travel, Laravel Style! 🔮⏳ Title: **How to Contribute Like a Rockstar 🎸** Title: **Welcome to Laravel's Magical Terminal Tour!** 🎪🎧 Unleash the Power of Cache! (Or, How to Speed Up Your App Without Breaking a Sweat) Unlocking the Kingdom! (aka, Authentication in Laravel) URL Navigation: The Cosmic Wayfarer's Guide to Cyberspace! 🛸🚀 Welcome to Laravel Boost, the supercharger for your PHP applications! 🚀💨 Welcome to Laravel Land! 🌴🎉 Wickedly Wonderful Blade Templates! 🧙‍♂️🔮