Oh Dear is the all-in-one monitoring tool for your entire website. We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that paired with a developer friendly API and kick-ass documentation. O, and you'll also be able to create a public status page under a minute. Start monitoring using our free trial now.

New features in our packages

Original – by Freek Van der Herten – 3 minute read

Every time our team releases a package I have the habit of writing an introductory blogpost. But after the initial release most pages gain more features through PRs by the community and ourselves. Mostly these new feature go unnoticed. That's why I plan on regularly writings posts on noteworthy changes across our repos.

Browsershot

This package makes it easy to convert any webpage (or html string) to an image or a pdf. Under the hood headless Chrome is leveraged. A while ago I took the time to add a new bodyHtml method to it. Here's how that can be used:

Browsershot::url('https://spatie.be')->bodyHtml();

The method returns the html of the dom after JavaScript has been executed. Pretty cool.

Among our packages there's also a powerful crawler. bodyHtml paved the way for making that crawler execute JavaScript as well. So now it can also find links that were injected by JavaScript scripts on your site.

Our laravel-sitemap package uses that crawler to automatically create a sitemap of your site. Now that the crawler can execute JavaScript, the sitemap generator can now add pages which are linked to by JavaScript injected links.

laravel-medialibrary

Our medialibrary is a pretty powerful package that can associate all sort of files with eloquent models. Here's a video that demonstrates what the package is capable of.

A PR by Alex Vanderbist makes it possible to generate temporary URLs to files that are stored on S3.

Here's how you can do that

$yourModel
   ->getMedia()
   ->first()
   ->getTemporaryUrl(Carbon::now()->addMinutes(5), 'thumb'); // Temporary S3 url

laravel-translatable

This package makes it easy make eloquent models translatable. Translations are stored as json. There is no extra table needed to hold them. Previously a translation should be set like this:

$yourModel->setTranslation('name', 'en', 'Name in English')

A PR by flofloflo adds an alternative way to go about this:

// assuming your the locale of the app is set to `en`
$yourModel->name = 'Name in English

Feels much more natural.

laravel-demo-mode

Our demo mode package provides a middleware that can protect your work in progress from prying eyes. Visitors should first visit a specific (secret) url before they can see that content of the project you're building.

A PR by Alex Vanderbist added these two options to the config file that make it possible to make a whitelist on an IP address basis.

/**
 * The following IP addresses will automatically have access to the app
 * without having to pass the `demoAccess` route.
 */
'authorized_ips' => [

],

/**
 * If strict mode is enabled then only the IP addresses listed in `authorized_ips` are allowed.
 * Vistors won't be able to gain access by visiting the  `demoAccess` route anymore.
 */
'strict_mode' => false,

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

What are your thoughts on "New features in our packages"?

Comments powered by Laravel Comments
Want to join the conversation? Log in or create an account to post a comment.