How to encrypt & upload large files to Amazon S3 in Laravel

How to encrypt & upload large files to Amazon S3 in Laravel

https://ift.tt/2QmSQqB

Creating Queueable Jobs

Next, let’s create the two queueable jobs that we use for encryption and uploading to S3:

php artisan make:job EncryptFilephp artisan make:job MoveFileToS3

This will create two files in app/Http/Jobs : EncryptFile.php and MoveFileToS3.php. These jobs will accept a param in the constructor, which represents the filename. We add the functionality of encrypting and uploading to S3 in the handle method. This is what the two jobs look like:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use SoareCostin\FileVault\Facades\FileVault;

class EncryptFile implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

protected $filename;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct($filename)
{
$this->filename = $filename;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
FileVault::encrypt($this->filename);
}
}
<?php

namespace App\Jobs;

use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\File;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;

class MoveFileToS3 implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

protected $filename;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct($filename)
{
$this->filename = $filename . '.enc';
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// Upload file to S3
$result = Storage::disk('s3')->putFileAs(
'/',
new File(storage_path('app/' . $this->filename)),
$this->filename
);

// Forces collection of any existing garbage cycles
// If we don't add this, in some cases the file remains locked
gc_collect_cycles();

if ($result == false) {
throw new Exception("Couldn't upload file to S3");
}

// delete file from local filesystem
if (!Storage::disk('local')->delete($this->filename)) {
throw new Exception('File could not be deleted from the local filesystem ');
}
}
}

As you can see, the EncryptFile job is simple — we are just using the FileVault package to encrypt a file and save it into the same directory, with the same name and the .enc extension. It’s exactly what we were doing before, in the HomeController’s store method.

For the MoveFileToS3 job, we are first using the Laravel putFileAs method that will automatically stream our file to S3, following the same directory convention as we had on the local filesystem.

We are then calling the PHP gc_collect_cycles function, in order to force collection of any existing garbage cycles. In some cases, if we don’t run this function then the file will remain locked and we won’t be able to delete it in the next step.

Finally, we are deleting the file from the filesystem and throwing Exceptions if the upload or the delete processes fail.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 9, 2019 at 09:00AM

Redirect www to non-www url’s in Laravel

Redirect www to non-www url’s in Laravel

https://ift.tt/2w4aNU6

I want my site to show as robindirksen.nl and not www.robindirksen.nl in the search results or ay other place, but how do you handle the removal of www in your application so you don’t lose your visitors?

There are a few ways how you can solve this. I recommend the server side (for example nginx or htaccess) above application based redirects (for example Laravel) because these will also redirect static files to the non-www version of your site.

Nginx configuration

You can make a new configuration in your configuration directory, this is usually in the /etc/nginx/conf.d/ directory. You can make a file (for example: /etc/nginx/conf.d/redirect.conf) and place the following configuration:

server { server_name www.robindirksen.nl; return 301 $scheme://robindirksen.nl$request_uri; } 

This will redirect everything that requests www.robindirksen.nl to the non-www version, robindirksen.nl.

.htaccess file

In a Laravel application you will find a .htaccess file in your public folder. Here you can add the following code to redirect the visitors.

RewriteEngine On RewriteCond %{HTTP_HOST} ^www.robindirksen.nl$ [NC] RewriteRule ^(.*)$ http://robindirksen.nl/$1 [R=301,L] 

To enable redirect you have to install mod_rewrite to the server and switch RewriteEngine to on.

Laravel Application

One of the ways to do this is by making a middleware and enable this to all your requests.

<?php namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Redirect; class RedirectToNonWwwMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (substr($request->header('host'), 0, 4) == 'www.') { $request->headers->set('host', 'robindirksen.nl'); return Redirect::to($request->path()); } return $next($request); } } 

After you’ve made your middleware you need to add it to the requests, this can be done by adding it to all of the requests (web, api etc) or only the web.

To add it to all of your requests, you can add the middleware (\App\Http\Middleware\TrustProxies::class) to the $middleware array, then it will look sometime like this:

<?php namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array */ protected $middleware = [ \App\Http\Middleware\CheckForMaintenanceMode::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \App\Http\Middleware\TrustProxies::class, ]; 

It’s also possible to only add it to the web-group requests (and not your api endpoints). With a basic Laravel 6 installation it will be added to all the requests made to the routes defined in routes/web.php.

<?php namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's route middleware groups. * * @var array */ protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\HttpsProtocolMiddleware::class, \App\Http\Middleware\RedirectToNonWwwMiddleware::class ], 'api' => [ ... ], ]; } 

Please pay attention, when you have likes to static files (like images, css or javascript) you have to enable htaccess or nginx redirects, otherwise those keep be served from the www version. This happens because the static files won’t boot the framework what means it don’t received the redirect.

Which status code do I need to use?

Last but not least, which redirect http code do you need to use? It’s really simple, you want to permanently show your non-www site in the results, then you redirect with a 301 status code.

Sometimes it can happen to only redirect the users for a specific time to another url, then you want a temporarily redirect. This can be done by redirecting with a 302 status code.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 9, 2019 at 09:00AM

Laravel API explorer package

Laravel API explorer package

https://ift.tt/2QnXKDU

Laravel API explorer

Latest Version on Packagist Total Downloads

Interactive Laravel API explorer. You don’t need to write/update documentation for your API. On the fly, Your API documentation will always be available in an interactive way.

Features

  • Quick install (one-step install, no code change needed);
  • Zero config needed;
  • Store config/parameters to be used anytime;
  • Variables: you can set variables (like id’s, tokens, etc. to be used in any place like querystring, header, body, etc.);
  • Global headers: You can set global headers (like tokens, content-type, etc.) to be used in all requests.

Live Demo

https://laravel-api-explorer-demo.herokuapp.com/api-explorer

Using variables

You can click on top right icon (wrench) and add your variables. When you will need to set some querystring parameter, header value, body content, etc., you can use ${VARIABLE_NAME}, and this placeholder will be replaced by your variable.

Using global headers

If you API needs some header in all request (or almost), you can set global headers instead of create these headers for every request. You can click on top right icon (wrench) and add your global headers.

Screenshots

Routes list

Routes list

Route info

Route info

Request/response

Request/response

Response info

Response info

Installation

Via Composer

$ composer require netojose/laravel-api-explorer

Usage

You just need access yourdomain.com/api-explorer

Configuration

Optionally you can copy config file to override default package configuration

php artisan vendor:publish --provider="NetoJose\LaravelApiExplorer\LaravelApiExplorerServiceProvider"

Now you have a config/laravelapiexplorer.php file inside your project,and you can make your changes. Available configurations:

Configuration Description Default
enabled Determine if the explorer will available true
route The route to access explorer page api-explorer
match Pattern to routes to be available on explorer api/*
ignore Array of routes to be ignored. You can use a pattern of a route path or route name [,’/’,]

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email sputinykster@gmail.com instead of using the issue tracker.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 9, 2019 at 09:00AM

Diana Prince reunites with her long-lost love in first Wonder Woman 1984 trailer

Diana Prince reunites with her long-lost love in first Wonder Woman 1984 trailer

https://ift.tt/38maMc8

Gal Gadot reprises her role as everyone’s favorite Amazonian demigod in Wonder Woman 1984.

Diana Prince faces off against two new formidable foes and reunites with an old love in the hotly anticipated first trailer for Wonder Woman 1984, with Gal Gadot reprising her titular role. Director Patty Jenkins unveiled the trailer today at Comic Con Experience (CCXP) in Sao Paulo, Brazil.

Inspired by the comic book heroine created by William Moulton Marston in the 1940s for DC Comics, Wonder Woman made her big-screen debut in the DCEU with 2016’s Batman v Superman: Dawn of Justice, followed by 2017’s Justice League. The first fell short of box office expectations; the second bombed outright. So when Jenkins took on Wonder Woman’s origin story, she deliberately departed from the grim humorlessness and dark sensibility of those earlier films, bringing a brighter energy and wit to her tale, along with the usual action. That vision paid off: Wonder Woman went on to gross $821 million worldwide and earned critical raves, making it the most successful of the DCEU films thus far.

Jenkins first broached the possibility of a sequel shortly after the first film’s release in June 2017, and principal photography began a year later. It has been described as a standalone film rather than a direct sequel, “in the same way that Indiana Jones or [James] Bond are, instead of one continuous story that requires many installments.” (That standalone strategy worked well for Warner Bros’  2019 box office smash Joker, which became the first R-rated film to gross over $1 billion worldwide.)

This second film is set almost seventy years after the original film. “In this movie we find [Diana] in 1984 and [she] is quite lonely — she’s lost her friends and doing what she needs to do,” Gadot said at CCXP. “She’s helping mankind and saving them until something crazy happens to her.”

  • Wonder Woman 1984 finds the titular heroine (Gal Gadot) in a lonely place.

    YouTube/Warner Bros

  • She still misses her WWI love, Steve Trevor (Chris Pine).

    YouTube/Warner Bros

  • Nonetheless, when violence breaks out in a local mall, she swoops in to save the day.

    YouTube/Warner Bros

  • Kristen Wiig plays Barbara Ann Minerva, who becomes arch-nemesis Cheetah.

    YouTube/Warner Bros

  • Pedro Pascal plays business entrepreneur Maxwell Lord, who has some sort of villainous plan.

    YouTube/Warner Bros

  • Diana senses a presence at a gala.

    YouTube/Warner Bros

  • Reunited with Steve—but how?

    YouTube/Warner Bros

  • Steve is a man out of time.

    YouTube/Warner Bros

  • Wielding the golden lasso.

    YouTube/Warner Bros

  • A swift kick takes out an opponent.

    YouTube/Warner Bros

  • Diana and Steve experience some fireworks.

    YouTube/Warner Bros

  • Flashback to young Diana in Themyscira.

    YouTube/Warner Bros

  • Diana competes in an Amazonian tournament.

    YouTube/Warner Bros

  • Wonder Woman unveils her golden armor.

    YouTube/Warner Bros

This being the 1980s, Diana is operating in a Cold War scenario, taking on Pedro Pascal’s villainous Maxwell Lord, a shrewd and powerful businessman. Kristen Wiig also co-stars as Barbara Ann Minerva, a British archaeologist in the comic books who becomes Wonder Woman’s arch-nemesis Cheetah. Connie Nielsen and Robin Wright reprise their roles as Diana’s mother, Hippolyta, and aunt, Antiope, respectively, in flashbacks to Diana’s Amazonian upbringing on Themyscira.

As New Order’s “Blue Monday” plays in the background, we see Diana having some heart-to-heart girl talk with Wiig’s Minerva about long-lost loves and a glimpse of an old photograph of Steve Trevor. “My life hasn’t been what you probably think it has,” Diana tells Barbara. “We all have our struggles.” Then trouble breaks out at a local supermall, and Diana intervenes to restore order. Inside the mall there are walls of TVs that just happen to be showing Maxwell Lord giving a motivational pitch. “Life is good but it can be better,” he says. “All you need is to want it. Think about finally having everything you always wanted.”

Lord has had various incarnations in the comics, including one where he had supernatural powers of persuasion. It’s unclear from the trailer what, if any, powers he displays in this film, but there are hints he might play some role in the miraculous reappearance of Steve while Diana is attending a gala. We see Diana and Steve’s emotional reunion, and then a shot of Lord declaring he will now take what he wants in return.

The rest of the trailer is a series of action shots as Diana and Steve work together once again to thwart whatever evil plan is threatening the day—including flashbacks to a young Diana competing in an Amazonian tournament, and a glorious shot of Diana’s iconic golden armor. But we don’t get to see Wiig in full Cheetah mode, which is a shame.

Wonder Woman 1984 hits theaters June 5, 2020. If it’s as successful as its predecessor, we can probably expect a third Wonder Woman film. Jenkins told the Hollywood Reporter earlier this year she has already mapped out the plot for a third installment, in a more contemporary setting.

Listing image by YouTube/Warner Bros

geeky

via Ars Technica https://arstechnica.com

December 8, 2019 at 06:47PM

To measure sales efficiency, SaaS startups should use the 4×2

To measure sales efficiency, SaaS startups should use the 4×2

https://ift.tt/2YoL3eJ

Brian Ascher
Contributor
Brian Ascher is a partner at Venrock, where he invests broadly across enterprise and fintech and serves on the boards of several companies, including Personal Capital, 6Sense, Socrates AI, Dynamic Signal, Retail Solutions, SmartBiz Loans, and Inrix.

Once you’ve found product/market fit, scaling a SaaS business is all about honing go-to-market efficiency.

Many extremely helpful metrics and analytics have been developed to provide instrumentation for this journey: LTV (lifetime value of a customer), CAC (customer acquisition cost), Magic Number and SaaS Quick Ratio are all very valuable tools. But the challenge in using derived metrics such as these is that there are often many assumptions, simplifications and sampling choices that need to go into these calculations, thus leaving the door open to skewed results.

For example, when your company has only been selling for a year or two, it is extremely hard to know your true lifetime customer value. For starters, how do you know the right length of a “lifetime?”

Taking one divided by your annual dollar churn rate is quite imperfect, especially if all or most of your customers have not yet reached their first renewal decision. How much account expansion is reasonable to assume if you only have limited evidence?

LTV is most helpful if based on gross margin, not revenue, but gross margins are often skewed initially. When there are only a few customers to service, cost of goods sold (COGS) can appear artificially low because the true costs to serve have not yet been tracked as distinct cost centers as most of your team members wear multiple hats and pitch in ad hoc.

Likewise, metrics derived from sales and marketing costs, such as CAC and Magic Number, can also require many subjective assumptions. When it’s just founders selling, how much of their time and overhead do you put into sales costs? Did you include all sales-related travel, event marketing and PR costs? I can’t tell you the number of times entrepreneurs have touted having a near-zero CAC when they are just starting out and have only handfuls of customers — which were mostly sold by the founder or are “friendly” relationships.

Even if you think you have nearly zero CAC today, you should expect dramatically rising sales costs once professional sellers, marketers, managers, and programs are put in place as you scale.

One alternative to using derived metrics is to examine raw data, which is less prone to assumptions and subjectivity. The problem is how to do this efficiently and without losing the forest for the trees. The best tool I have encountered for measuring sales efficiency is called the 4×2 (that’s “four by two”) which I credit to Steve Walske, one of the master strategists of software sales, and the former CEO of PTC, a company renowned for its sales effectiveness and sales culture. [Here’s a podcast I did with Steve on How to Build a Sales Team.]

The 4×2 is a color-coded chart where each row is an individual seller on your team and the columns are their quarterly performance shown as dollars sold. [See a 4×2 chart example below].

Sales are usually measured as net new ARR, which includes new accounts and existing account expansions net of contraction, but you can also use new TCV (total contract value), depending on which number your team most focuses. In addition to sales dollars, the percentage of quarterly quota attainment is shown. The name 4×2 comes from the time frame shown: trailing four quarters, the current quarter, and the next quarter.

Color-coding the cells turns this tool from a dense table of numbers into a powerful data visualization. Thresholds for the heatmap can be determined according to your own needs and culture. For example, green can be 80% of quota attainment or above, yellow can be 60% to 79% of quota, and red can be anything below 60%.

Examining individual seller performance in every board meeting or deck is a terrific way to quickly answer many important questions, especially early on as you try to figure out your true position on the Sales Learning Curve. Publishing such leaderboards for your Board to see also tends to motivate your sales people, who are usually highly competitive and appreciate public recognition for a job well done, and likewise loathe to fall short of their targets in a public setting.

4x2 chart venrock saas

A sample 4×2 chart.

Some questions the 4×2 can answer:

Overall performance and quota targets

How are you doing against your sales plan? Lots of red is obviously bad, while lots of green is good. But all green may mean that quotas are being set too low. Raising quotas even by a small increment for each seller quickly compounds to yield big difference as you scale, so having evidence to help you adjust your targets can be powerful. A reasonable assumption would be annual quota for a given rep set at 4 to 5 times their on-target earnings potential.

technology

via TechCrunch https://techcrunch.com

December 6, 2019 at 06:10PM

Laravel and MySQL 8: Fixing MySQL Server Has Gone Away Error

Laravel and MySQL 8: Fixing MySQL Server Has Gone Away Error

https://ift.tt/2sMWrFn

Laravel and MySQL 8: Fixing MySQL Server Has Gone Away Error

If you’ve tried to upgrade your Laravel applications to use MySQL 8, you might have run into the following error that left you scratching your head:

SQLSTATE[HY000] [2006] MySQL server has gone away 

The php.net manual has an outdated (but still relevant explanation):

When running a PHP version before 7.1.16, or PHP 7.2 before 7.2.4, set MySQL 8 Server’s default password plugin to mysql_native_password or else you will see errors similar to The server requested authentication method unknown to the client [caching_sha2_password] even when caching_sha2_password is not used.

This is because MySQL 8 defaults to caching_sha2_password, a plugin that is not recognized by the older PHP (mysqlnd) releases. Instead, change it by setting default_authentication_plugin=mysql_native_password in my.cnf. The caching_sha2_password plugin will be supported in a future PHP release. In the meantime, the mysql_xdevapi extension does support it.

We should expect a future version of PHP to have support for caching_sha2_password authentication. However, in the meantime, you can fix it quickly with the following changes:

First, we need to find the paths MySQL will look for a configuration file. We can find out by running mysql --help. The command prints out a lot of info, but you’re looking for something like the following:

mysql --help ... Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 

Take the paths from your command output and adapt the following with the paths you get from mysql --help:

ls -la \ /etc/my.cnf \ /etc/mysql/my.cnf \ /usr/local/etc/my.cnf \ ~/.my.cnf ls: /etc/my.cnf: No such file or directory ls: /etc/mysql/my.cnf: No such file or directory -rw-r--r-- 1 paul staff 61 Dec 5 19:40 /Users/paul/.my.cnf -rw-r--r-- 1 paul admin 113 Oct 28 2017 /usr/local/etc/my.cnf 

I like to manage the file from ~/.my.cnf, but unless you’ve previously done that, you’ll probably have to create the file if you want to manage configuration from that path.

I suggest you use the ~/.my.cnf path, but whatever path you determine you need to add the following:

[mysqld] default_authentication_plugin=mysql_native_password 

If you’re using Homebrew and you want to update the /usr/local/etc/my.cnf file, add the following at the end of the file under [mysqld]:

# Default Homebrew MySQL server config [mysqld] # Only allow connections from localhost bind-address = 127.0.0.1 default_authentication_plugin=mysql_native_password 

Last, you need to restart MySQL using whatever method is appropriate for your system. If you’re using Homebrew on a Mac, you can run brew services:

brew services restart mysql 

If you’re using Docker, here’s an example Docker Compose configuration to get MySQL 8 working with Laravel and other PHP projects:

services: # ... mysql: image: mysql:8.0 # PDO Doesn't support MySQL 8 caching_sha2_password Authentication # @see https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password command: --default-authentication-plugin=mysql_native_password ports: - 13306:3306 volumes: - mysql:/var/lib/mysql environment: MYSQL_DATABASE: my_database MYSQL_ROOT_PASSWORD: root volumes: mysql: driver: "local" 

With that change in place, you should be able to connect to MySQL 8 from PHP applications!


Filed in: News


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.

programming

via Laravel News https://ift.tt/14pzU0d

December 6, 2019 at 09:29AM

What metrics I’m using for real-time monitoring of my Laravel application

What metrics I’m using for real-time monitoring of my Laravel application

https://ift.tt/2U5UUEw

Hi I’m Valerio, software engineer and creator of Inspector.

As product owner I know that being able to prevent users from noticing an application issue is probably the best way for developers to contribute to the success of a software-based business.

We could talk about user complaints, customer churn, a thousand other things, but in short, in a highly competitive market any application error can expose developers to competitive or even financial risks. We publish new code changes almost every day, and it’s quite impossible to anticipate all the problems that could happen after every release.

It’s too important for developers to catch errors on their products —before— their users stumble into the problem drastically reducing negative impact on their experience.

I’m refine and search every day new metrics to move my business forward, and my product itself is a tool that provide instant and actionable metrics to its users, so I study and practice a lot to find the best possible information to avoid unnecessary risks.

I’m not interested to create charts that looks good (even if they are), my priority are useful, indeed needful metrics to distinguish between something that doesn’t need to be rushed and something that needs immediate attention to keep my application (and my business) stable and secure.

Why averages don’t work?

Anyone that has ever made a decision uses or has used averages. They are simple to understand and calculate.

But although all of us use them, we tend to ignore just how wrong the picture that averages paint of the world is. Let me give you a real-world example. 

Imagine being a Formula 1 driver.

Your average “execution” time for a lap is comparable with the top three in the ranking, but you are in fifth position. 

According to the average, everything is fine. According to your fans, it’s not so good.

Your “Team Principal” – the person who owns and is in charge of your team during the race weekend –  knows that relying on averages is not a good way to understand what’s going wrong. He know that, when it comes to making decisions, the average sucks.  When calculating the average, it’s likely that in some races you’re so fast that you can make up for the next four races with bad performances.

As an F1 driver you can compare your “execution” time and results with other drivers, but with your application you are alone, the only feedback you have is customer churn.

Your team principal knows that focusing too hard on the best performances is not so useful to understand what’s going wrong and how to fix it (car settings, pit stop, physical training, etc.).

He recalculates the average taking into consideration only the worst 5% of your races (95th percentile). Isolating these executions from the noise he can now analyze them and clearly see that every time something goes wrong it is because of the pit stop.

Measuring in real time the worst 5% of your application cycles gives you the same opportunity. You’re able to understand what is going wrong when your application slow down (a too time-consuming query, slow external services, etc.) and avoid bad customer experiences, because you always have the right information before your users stumble into the problem.

Inspector’s timeline

In a typical web back-end we experience the same scenario: some transactions are very fast, but the bulk are normal. The main reason for this scenario is failed transactions, more specifically transactions that failed fast, not for bugs but due to user errors or data validation errors.

These failed transactions are often magnitudes faster than the real ones because the application barely starts running and then stops immediately; consequently, they distort the average.

The secret to using averages successfully is: “Measure the worst side”

Inspector shows you the “execution time analysis” of the worst 50% (Median) and the worst 5% (95th percentile) of application cycles.

As you can see the median (blue line) is rather stable but has a couple of jumps. These jumps represent real performance degradation for the majority (50%) of the transactions. The 95th percentile (red line) is more volatile, which means that the outliers slowness depends on data, user behavior, or external services performance.

In this way you will automatically focus only on transactions that have bad performance or problems that need to be solved. 

Inspector eliminates any misunderstanding and offers a dashboard that informs you directly about things that can cause problems to your users and even to your business, including errors and unexpected exceptions, as you can read about in the first part of this series [Laravel Real-Time monitoring & alerting using Inspector].

Automatic alerting

In real-world environments, performance gets attention when it is poor and has a negative impact on the business and users. But how can we identify performance issues quickly to prevent negative effects? 

We cannot send out alerts for every slow transaction. In addition, most operations teams have to maintain a large number of applications and are not familiar with all of them, so manually setting thresholds can be inaccurate, time-consuming and leave a huge margin for errors.

1 — Blue line still flat, Red line jump (low priority)

If the 5% degrade from 1 second to 2 seconds while the 50% is stable at 700ms. This means that your application as a whole is stable, but a few outliers have worsened. It’s nothing to worry about immediately but thanks to inspector you can drill down into these transactions to inspect what happened.

Inspector metrics don’t miss any important performance degradation, but in this case we don’t alert you, because the issue involves only a small part of your transactions and is probably only a temporary problem! Thanks to Inspector you can check if the problem repeats itself and eventually investigate why.

2 — Blue line jump, Red line still flat (high priority)

If the worst 50% moves from 500ms to 800ms I know that the majority of my transactions are suffering an important performance degradation. It’s probably necessary to react to that.

In many cases, we see that the red line does not change at all in such a scenario. This means the slow transactions didn’t get any slower; only the normal ones did with a high impact on your users.

In this scenario Inspector will alert you immediately.

Conclusion

Your team can now work for a better pit stop and you will soon be able to compete with the best drivers in the league. Measure continuously potential problems is the secret behind the great Formula 1 teams to achieve success not once, but to remain in the top teams for all the years to come.

Inspector is a developer tool that drastically reduce the impact of an application issue because you will be aware of it before your users stumble into the problem.

Thank you so much for reading it. To make Inspector more sophisticated and mature, it will not be possible to accomplish without your help. Don’t hesitate to share your thoughts on the comment below or drop in live chat on our website! Let’s make it together.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 5, 2019 at 08:48AM

New Package: Laravel Invoices – Generate PDF Flexibly

New Package: Laravel Invoices – Generate PDF Flexibly

https://www.youtube.com/watch?v=h9iuXm23Xe0

Presenting to you our totally new package. While working with invoices on client projects, we didn’t find convenient way to generate PDFs.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 5, 2019 at 08:48AM