Favourite Laravel packages I always install

I thought it might be helpful for me to share a handful of packages which I find myself installing whenever I start a new Laravel application. Let me know if there are any missing!

Laravel Debug bar

barryvdh/laravel-debugbar (Github / Packagist)

Probably the first package I install in every Laravel project is the laravel Debug bar by Barry vd. Heuvel. With over 13 million installes I am not the only person who thinks this is an amazing package. You get a bar at the bottom of the browser window which will show you queries, information about the current Route, the currently loaded views, events and the Laravel version and Environment. And that’s just s small list of the things you can use it for.

composer require barryvdh/laravel-debugbar --dev

Laravel Telescope

laravel/telescope (Official Laravel Docs / GitHub / Packagist)

A very powerful ‘telescope’ into everything that your application is doing. I have only recently started to look at this but it’s been a great help for a recent application we have been working on.


Laravel IDE Helper

barryvdh/laravel-ide-helper (GitHub / Packagist)

A no brainer for anyone who uses PHPStorm. It will basically build some meta files fo the IDE to use which will help with all sorts of magic.

composer require --dev barryvdh/laravel-ide-helper php artisan clear-compiled php artisan ide-helper:meta php artisan ide-helper:generate

Laravel Query Detector

beyondcode/laravel-query-detector (GitHub / Packagist)

The Laravel N+1 query detector helps you to increase your application’s performance by reducing the number of queries it executes. This package monitors your queries in real-time, while you develop your application and notify you when you should add eager loading (N+1 queries). (Taken directly from the Readme)

composer require beyondcode/laravel-query-detector --dev php artisan vendor:publish --provider=BeyondCode\QueryDetector\QueryDetectorServiceProvider 

PHP Coding Standards Fixer

friendsofphp/php-cs-fixer (GitHub / Packagist)

I have been a huge fan of PSR-2 for a long time and if you have ever worked on a project with me you know I can be a sucker about PR’s with code style errors/issues. PHPStorm has a build in Code Style fixer and there are a number of other ways you can set up automatic code style fixing but I prefer this method. I tweak a few things in the config so that I can match my own specific style. I have included a .php_cs config file below so you can use this if you wish. I also use the Makefile as a little helper so that I can run make fix from my project root in a terminal.

I highly recommend you make use of this package locally but if you want to look at automating this and other Laravel specific code styles like making sure you are doing things “The Laravel Way’ then Check out Laravel Shift

composer require --dev friendsofphp/php-cs-fixer make test make fix

Laravel UUID

jamesmills/eloquent-uuid (GitHub / Packagist)

A Laravel Eloquent Model trait for adding and using a uuid with models. The trait listens to the creating event. It generates a new UUID and saves it in the uuid column on the model.

I personally like adding UUID’s to every entity in my application. There are the odd occurrences which I don’t do this. The main reason is that I find they much nicer to work with when it comes to URL’s and API’s. You can hide the auto-increment ID’s from the public eye and I personally just think they look and work better.

composer require jamesmills/eloquent-uuid

Just add the package and make sure your Entity/Model uses theHasUuidTrait. When you save the model then a UUID will automatically be added.

<?php namespace App; use JamesMills\Uuid\HasUuidTrait; class User extends Eloquent { use HasUuidTrait; }

Laravel Timezones

jamesmills/laravel-timezone (GitHub / Packagist)

Laravel Timezones package An easy way to set a timezone for a user in your application and then show date/times to them in their local timezone. I think this is pure magic!

I wrote a blog post specifically about the Laravel Timezones package where I go into a little more detail about why and how to use this package.

I don’t install this in every application but I have found that almost all of my applications have needed to show times and dates to a user in their specific timezone so I usually just install it at project setup so I have it there when needed.

composer require jamesmills/laravel-timezone // This will add a timezone column to your users table. php artisan migrate

It has a number of helpful features like blade directives

@displayDate($post->created_at) // 4th July 2018 3:32:am

Related

via Laravel News Links
Favourite Laravel packages I always install

Two Laravel Developers Building SaaS – SaaS Reality

The beginning…

We are two experienced developers and entrepreneurs who are sharing our journey as we build, launch and run SaaS businesses.

Join us, Simon and Dean, as we share our ‘accountability’ updates with the world.

Come along with us through the highs and lows as we talk openly about the challenges and triumphs of running an online SaaS business.

In this first episode you get to meet the hosts (us):

Simon, the young energetic Dad, already a successful SaaS founder with his Snapshooter.io product is scratching his own itch and building Automaily.

Dean, a survivor of the pre-internet corporate IT world and an ex CTO/Technical Director of a 7 figure web agency brings his experience and maturity of the enterprise to the SaaS world.

About Episode 1:

In this, our first episode, you’ll discover why we started this podcast and why we are sharing our journey with you.  Why we think this podcast is needed and who inspired us.

About Automaily:

Automaily is a churn busting and dunning automation tool with fully configurable workflows designed to help you recover lost and churned revenue.  

It also takes care of all the tedious and boring follow up emails when chasing down failed payments.

About CloudInsights.app

CloudInsights is tackling a hard problem, how to reduce your AWS bill and save time and money.

Dean’s product scans your AWS infrastructure and analyses your costs and usage data. It identifies unused, under-utilised and forgotten servers and resources.

With this knowledge you can right-size, shut down or refactor the troublesome parts of your Amazon Web Services infrastructure to save money and reduce your support and DevOps overheads.

Links:

People and podcasts mentioned during the episode and who inspired this podcast

via Laravel News Links
Two Laravel Developers Building SaaS – SaaS Reality

Laravel Google Translate

Laravel Google Translate

Laravel Google Translate is a package that provides an artisan console command to translate your localization files with the Google translation API. You can either leverage stichoza/google-translate-php without an API key or configure your Google Translate API key.

The console command php artisan translate:files walks you through some prompts to determine how to proceed with your translations files:

Future goals of this package include handling vendor translations, a web interface, and adding other translation APIs such as Yandex, Bing, etc.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at tanmuhittin/laravel-google-translate.


Filed in: News / packages


Enjoy this? Get Laravel News delivered straight to your inbox every Sunday.

No Spam, ever. We’ll never share your email address and you can opt out at any time.

via Laravel News
Laravel Google Translate

Congress Pushing A Terrible Bill To Massively Expand Patent Trolling

For most of the history of Techdirt, we’ve talked about what an incredible mess the US patent system has been. There are many, many reasons for this, but a big one was that for decades, the appeals court that handles all patent cases, the Court of Appeals for the Federal Circuit (or CAFC), kept expanding what it considered to be patentable subject matter, and the Supreme Court completely ignored the issue. This culminated, ridiculously, in the State Street decision, which massively expanded what was considered patentable software (before that there was software covered by patents, but it was very, very limited). What made this situation truly hellish for innovators, is that (1) the software world was exploding with all different kinds of apps, and (2) almost no software was documented in the very few areas where patent examiners look for prior art: mainly, other patent applications and scientific journals. There was no need to document software in those places, because (1) when most people recognized software shouldn’t be patented, very few even tried, and (2) why would you?

That resulted in a perfect storm in which patent trolls rushed in to fill the void. Tons upon tons of ridiculously broad patents were filed (or older ones were dug up and "repurposed" for use in trolling). Then it just became a shakedown game of numbers. Find companies doing something vaguely like what’s broadly and oddly described in your patent, tell them they’re infringing — and offer to "settle" for less than the cost to win in court.

The tide started to change over the last decade and a half or so, in part because of a few changes to the law, but more importantly, the Supreme Court started to wake up to the fact that the CAFC had gone rogue and had massively rewritten patent law. And then over a period of about a decade, case by case by case, the Supreme Court smacked down CAFC. Two of the biggest such smackdowns came in the Mayo Labs ruling in 2012 which rejected medical diagnostic patents, and the Alice ruling in 2014, which rejected patents on software that performs "generic functions" (which is basically all software).

Both of these cases focused on Section 101 of the Patent Act, which defines what actually is patentable subject matter. It’s short and sweet:

Whoever invents or discovers any new and useful process, machine, manufacture, or composition of matter, or any new and useful improvement thereof, may obtain a patent therefor, subject to the conditions and requirements of this title.

In both of the cases mentioned above, the Supreme Court noted simply that 101 doesn’t cover "laws of nature, natural phenomena, and abstract ideas" as decided in an earlier case that CAFC had ignored for two decades, Diamond v. Diehr. In the Mayo case, the court noted that medical diagnostics was trying to patent laws of nature. In the Alice case, "abstract ideas."

Since then, both cases have been incredibly useful in killing off a ton of truly awful patents. And the patent trolls and their friends have been really angry about this. And now it appears they’ve finally got a plan to reopen the patent trolling floodgates. And, they’ve got bipartisan members of both the House and the Senate to push a plan for them. In the Senate, Thom Tills and Chris Coons have announced plans to introduce a horrific bill to rewrite Section 101 in a manner that can only be called "Make Patent Trolls And Bogus Litigation Great Again." A House version is being introduced by Reps. Hank Johnson and Steve Stivers.

The biggest part of the bill is to remove the requirement that a patent be for an invention that is "new and useful." Yes, you read that right. The most fundamental part of a patent is that it’s to encourage people to invent something that is new and useful, and these elected officials want to do away with that. Then, they want to massively limit what is not patent eligible, demanding very narrowly defined areas, like "fundamental scientific principles" and "products that exist solely and exclusively in nature," rather than what we now have, which is "laws of nature." On the software side, they want to say that only "pure mathematical formulas" and "mental activities" would be excluded, but abstract ideas implemented in software? PATENT AWAY!

And, of course, the bill is explicit, that with this new list of narrowly defined exclusions, it would literally wipe away those big Supreme Court wins that have helped open up innovation and slowed down patent trolls.

This would be absolutely terrible for innovation.

Alex Moss, from EFF, has gone through and detailed just how massive a change this proposal would create and what a disaster it would be for companies that actually innovate (as opposed to those that just shake innovators down for money.) On the removal of "new and useful" from 101:

Removing the requirement that inventions actually be new and useful upends a fundamental Constitutional principle of patent law. The Constitution grants Congress the power to issue an “exclusive right,” such as a patent, only “[t]o promote the progress of science and useful arts.” The patent system’s entire purpose, in other words, is to encourage technological progress. Allowing patents on things that are neither new nor useful undermines the purpose of the Intellectual Property Clause.

Section 101’s purpose is to weed out patent applications that cannot possibly be inventive. The “existing statutory utility requirements” do not, and cannot, accomplish this. That’s because other parts of U.S. patent laws do not include a specific “utility” requirement. Section 102 and 103 set out requirements for determining whether an invention is obvious in view of pre-existing knowledge in the field—what is known as “prior art”—but courts and the Patent Office apply those requirements extremely narrowly.

It’s especially difficult to invalidate bad software patents under Sections 102 and 103. Because courts and the Patent Office didn’t start granting patents on software alone until the mid-1990s, there is a dearth of patents and patent applications that could be used to invalidate software patents under Sections 102 and 103. And because the code for most software products is not public, it isn’t readily available to others in court challenges.

So, yeah, that would be bad.

At this point, this is just a proposal, rather than an actual bill, but they promise to introduce it later this year. Patent trolls and some larger organizations that live off of patent licensing are likely going to push hard for this bill. It’s basically a full employment act for patent lawyers. What it’s not is a recipe for innovation. It is the reverse. Of course, because some people laughably believe that a patent itself is a sign of innovation, too many people incorrectly believe that "stronger" patent laws mean more innovation. That’s not how it works. Patent trolling scares off actual innovators, makes innovation much more costly, and blocks important innovations from the marketplace.

Already the quotes from the Senators and Representatives demonstrate the kind of innovation-ignorant arguments we’re likely to see in support of this bill. Coons falsely claims that "today US patent law discourages innovation in some of the most critical areas of technology, including artificial intelligence, medical diagnostics, and personalized medicine." This is laughable. There are massive innovations happening in all three of those fields. And part of that is because of decisions like Mayo and Alice opening up those fields and limiting some of the worst patent trolling.

Tills claims that this is to "reform our nation’s complicated patent process." It’s not that complicated. And removing the requirements for "new and useful" and making most software patentable again is going to create a huge mess of a patent thicket that will be a massive drain on innovation. That’s complicated.

Hopefully, reason will prevail and these elected officials will learn just how much harm they’re about to do to the sectors of the economy that are actually innovating — with less fear of bogus patents and widespread patent trolling. Bringing that back would be a total disaster for innovation.

Permalink | Comments | Email This Story

via Techdirt
Congress Pushing A Terrible Bill To Massively Expand Patent Trolling

OnVirtus Offering Online Firearms Education Taught by Top Professionals

You don’t need to wade through all the YouTube chaff any more looking for a few grains of wheat in search of worthwhile shooting lessons and tips. And getting access to learn from the industry’s top pros is difficult and expensive.

Now, however, OnVirtus, a new online education site, is offering firearms education featuring lessons from some of the best shooting professionals in the business.

TTAG readers can get a 20% discount off the subscription price by using discount code TTAG20 at checkout.

Here’s their press release . . .

OnVirtus Launches Its First Series of Classes from Shooting Professionals

Box Springs, GA – OnVirtus is pleased to introduce the new era of firearms education. During the 2019 NRA Annual Meetings, the OnVirtus.com website will launch its first series of classes taught by the most accomplished firearms professionals in the industry.

“In the past, it’s been difficult to gain access to high-level instructors without sacrificing a lot of time and money. We wanted to give everyone access to good, high quality, instruction,” said Daniel Horner, founder of OnVirtus. “If I had access to this type of a website when I was younger, it would have taken years off my training.”

OnVirtus hosts videos of the best instructors that have proven their capabilities in competition or combat.

With this initial launch, you will see lessons from:

  • Jerry Miculek – specializing in 3-gun and revolver
  • Shane Coley – specializing in USPSA Limited Division
  • Max Michel – specializing in USPSA Open and Carry Optics
  • Daniel Horner – specializing in 3-gun and long range rifle
  • Todd and Colby Hodnett – specializing in long range rifle and ballistics
  • Lena Miculek – specializing in PCC and 3-gun
  • Jake Vibbert – specializing in precision rifle
  • Brandon Green – specializing in NRA High Power
  • True Pearce – specializing in the legalities of concealed carry

More instructors will be added soon, to include:

  • Vincent Hancock – specializing in shotgun
  • JJ Racaza – specializing in IPSC Limited and Open
  • Eric Grauffel – specializing in IPSC
  • James Henderson – specializing in NRA Bullseye handgun
  • Kenda Lenseigna – specializing in cowboy mounted shooting

There are hours of content on the website, and more will be added on a constant basis. The price to access all the videos from all the instructors is only $124.99 for an annual membership. Videos are presented in small, specific clips that allow you to find exactly what you’re looking for in seconds. Furthermore, the members are encouraged to ask the instructor(s) questions so that future topics can be tailored to what the members want to learn more about.

Visit OnVirtus.com to accelerate your learning curve in multiple shooting disciplines.

via The Truth About Guns
OnVirtus Offering Online Firearms Education Taught by Top Professionals

How to Properly Mount a Rifle Scope

Mounting a new rifle scope correctly is pretty important. If done wrong, you will constantly struggle with finding a good position behind the scope and the adjustments you make when shooting won’t make sense.

There are two keys to properly mounting a scope. First, make sure the scope is in line with the barrel. Second, make sure the scope is square to the world.

You get the scope in line with the barrel by first getting the gun level, then placing the scope directly on top.  The scope is then leveled so that the vertical reticle line — and by extension the elevation adjustment — is in line with gravity. This is often done with bubble levels.

 

Level the gun by placing a bubble on a flat surface like the action rails or Picatinny/Weaver rails.

An example of a bubble level placed on the action rails. Courtesy Author

 

An example of a bubble level placed on a Picatinny rail. Courtesy Author

Once you know your rifle is level, you then level the scope by putting a bubble on top, specifically on the top of the elevation turret.

Courtesy Author

Once both bubbles read level you then torque the scope ring screws to spec without disturbing anything. The scope is now level to the gun which is level to the world. This will allow all drop compensation to work properly without adding mystery drift and unexplainable dope errors at distance.

Another good way to see if your reticle is properly level is to use a plumb line. It ultimately accomplishes the same thing as a bubble level, though it tends to be more accurate.

Ideally, I will do both. Hang a plumb line (something weighted at the end of a piece of string) in front of the rifle so it’s visible, but has a similar thickness to your scope’s reticle lines.

The white line is nylon string commonly found in hardware stores. Courtesy Author

Level the gun with a bubble, level the scope with a bubble and fine-tune the scope with the plumb line. There should be one consistent line from the string through the reticle.

It’s critical that the gun’s bubble be level when doing this. If the scope’s bubble is a little off, but the reticle matches the plumb line, I will defer to the plumb line. That’s because the turrets aren’t always perfectly square to the lead screw/reticle. Fine-tuning with a plumb line should eliminate small errors caused by this.

I hold to compensate for drop, so this is good enough for me. If you dial in for drop, you might want to run the elevation turret to the top of its movement and back down, ensuring that it stays in line with the plumb.

The reticle should be in line with the turret screw, so they should match, but scopes wear out, things break and manufacturers make mistakes. It doesn’t hurt to double-check that everything is running the way it’s supposed to.

The flat portion at the bottom of the turret housing is the best surface on a scope to use when squaring.

Unfortunately, it’s at the bottom, so not a very convenient place for a bubble. If you have a bubble setup that will work, use it on that surface instead of the top of the turret. I know guys who have stacked feeler gauges between the scope base and the top rail of the rifle to make them as parallel as possible.

This isn’t viable for all rifle and scope mount configurations, but I’ve heard it works quite well.

When tightening the scope ring halves together, you will have to do it in stages. In the beginning, the rings should be loose enough to allow the scope to move while being tight enough to stop it from flopping over due to the weight of the turrets.

My figures are more than enough for this. Courtesy Author

Once level, tighten it a little then re-confirm that everything is level. Sometimes the scope will move. You should have enough wiggle room for fine adjustments.

Carefully tighten to spec and re-confirm. You will want to tighten the screws down in a cross pattern and tighten both rings at the same time. Don’t tighten one completely before you’ve even started tightening the other.

Make sure the top half of the ring is evenly mounted. The gaps on either side of the scope should be equal.

Courtesy Author

Courtesy Author

Torque values for scope ring screws and scope mount cross bolts will vary. Refer to your product’s literature for its recommended inch-pound values. The Wheeler Engineering – Fat Wrench is inexpensive and handy for this job.

Never Loctite your ring screws. Torque them to spec and confirm torque before shooting.

Next is a little shooting voodoo; all the guys I’ve met who are obsessed with accuracy will torque their scope rings screws in the exact same pattern every time. That way the pressure is being applied exactly the same, minimizing any shifts that could be caused by new stress.

This is done when confirming that the screws are still torqued to spec before you go shoot. This is likely just superstition, but it also can’t hurt. It’s also not something I personally do.

Eye relief is the distance your eye should be from the scope to obtain the maximum field of view when looking at your target.

Too close or too far will result in scope shadow. Eye relief distance varies for different scopes and changes depending on how zoomed in it is. Set your eye relief to whatever position and power you will most likely be shooting in.

Keep in mind that your head’s natural position on the stock changes depending on your shooting position. It won’t be the same in the prone as it is when standing. If this is a short-range hunting rifle that will be shot from sticks on 4-6 power zoom, set up a similar shooting position to establish your eye relief.

The important part is that your head is in the same position on the stock when the eye relief is set. If you will be shooting the rifle from a bench with the zoom maxed out, set your eye relief for that. Get in position while sitting, zoom in all the way and move the scope forward or back until the eye relief is correct.

Depending on how your scope is mounted to the rifle, you may need to do this by sliding the scope itself forward and back inside the rings. Because of this I usually determine my eye relief before leveling the scope. If you have a ton of rail space like on a flat top AR-15, eye relief can be easily changed by moving the scope and rings forward or back.

A scope’s “correct” position on the rifle is 100% shooter-dependent. If you don’t have a specific position that you will be shooting in, set the eye relief in the prone position at max power. When shooting in alternate positions you will have some leeway and adjustment ability with your head position. When prone you can’t as easily or comfortably adjust your head position forward and back. That’s why setting the eye relief for this position is a good default.

If I have plenty of rail space to properly adjust my eye relief, I will also set the scope in the rings so that the turret housing is touching the back side of the front ring.

Courtesy Author

This may be more voodoo, but it was something my sniper section did. By butting the scope up to the front rings as pictured, you minimize the chance of the scope sliding in the rings under recoil.

The rearward recoil force of the gun when fired is sharp and strong. Throughout the entire firing cycle that’s when the scope is most likely to move in the rings.

Setting the scope in the rings like that is only possible if eye relief is not set by moving the scope in the rings. Since plenty of scopes are set without this in mind, it might not be a thing, so take it as you will.

Following that same principle of recoil being the strongest force exerted on the scope, press the mount forward on the rails as you tighten it down.

Courtesy Author

This too should eliminate any chance of the mount — and by extension the scope — moving under the force of recoil.

Lapping your rings increases the rings’ holding force by increasing the surface contact between ring and scope. It also evens out the pressure, decreasing or eliminating stress points and ensures that both rings are properly aligned with each other.

 

The Wheeler lapping bar used to lap the rings. Courtesy Scheels

Leveling scopes can be aggravating since they don’t always want to cooperate. It’s frustrating getting everything level the way you want only to have it move when you start tightening the screws. But, doing it right and getting it as close to perfect as possible is well worth the time and effort.

Mounting the rifle in a gun vise, shooting sled or something similar that gives you the flexibility to make the gun level while keeping it fixed in place is a big help. That being said, I’ve leveled more scopes with the rifle sitting on its bipod than otherwise.

There are also jigs like Badger Ordinance – Dead Level Scope Leveling Device that allow you to level the scope in the rings independent of the rifle, though this only works if you have the rail space to fine-tune your eye relief. You could try marking where you want the scope set in the rings for proper eye relief and then level it in the jig, ensuring the mark stays in the proper spot…if you really want to use the jig.

There are plenty of ways to level a scope. As is the case with so many things in the shooting world, the result outweighs the method. As long as the scope winds up properly leveled to the gun (and the world) you’ve succeeded.

via The Truth About Guns
How to Properly Mount a Rifle Scope