Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Learn to Create an RSS Feed from Scratch in Laravel
Apr 04, 2018 @ 15:47:52

On the Laravel News site there's a new tutorial showing you how to easily create an RSS feed with Laravel and the help of the spatie/laravel-feed package.

Creating an RSS feed in Laravel isn’t the most challenging task, but using a package and a few tips can help you create an RSS feed relatively quick.

We are going to use the spatie/laravel-feed package to walk through going from a brand new Laravel 5.6 project to serving RSS feeds.

The tutorial then goes through each step along the way, providing code and commands to get you up and running:

  • Setting up a new Laravel project
  • Modeling the data
  • Setting up the (event) model
  • Creating the Routes and the Events Controller
  • Linking to the feed

The result is a simple RSS feed that can be linked to from a link tag in your site and provide a list of upcoming events.

tagged: laravel tutorial rss feed spatie package

Link: https://laravel-news.com/learn-to-create-an-rss-feeds-from-scratch-in-laravel

Laravel News:
Uploading Avatar Images with Spatie’s Media Library
Mar 26, 2018 @ 15:48:05

On the Laravel News site, there's a new tutorial posted showing how you can use the Spatie Media Library package to help with the file uploads in your Laravel-based application to upload avatars for your users.

By default, the Laravel registration form contains only the name, email, and password, but often it’s useful to allow the user to upload a photo or an avatar. In this tutorial we will show you an easy way to add it, using [Spatie’s Media Library](https://github.com/spatie/laravel-medialibrary) package.

The remainder of the tutorial then breaks the implementation down into three steps:

  • Change the User Registration Form (to include the "avatar" field)
  • Upload and Store with the Media Library (installing the relation and changing the models)
  • Show an Avatar Thumbnail in the Top Navigation (using the package to resize the image)

Each step in the process includes the code or commands required to complete it. There are also several screenshots to help ensure you have the right information stored in your database.

tagged: tutorial upload avatar image spatie medialibrary package

Link: https://laravel-news.com/uploading-avatar-images

Sebastian De Deyne:
Server side rendering JavaScript from PHP
Mar 13, 2018 @ 15:21:24

Sebastian De Deyne has a tutorial posted to his site showing you how to use two packages to render Javascript on the server side via PHP.

Server side rendering is a hot topic when it comes to client side applications. Unfortunately, it's not an easy thing to do, especially if you're not building things in a Node.js environment.

I published two libraries to enable server side rendering JavaScript from PHP: spatie/server-side-rendering and spatie/laravel-server-side-rendering for Laravel apps.

Let's review some server side rendering concepts, benefits and tradeoffs, and build a server renderer in PHP from first principles.

The tutorial starts with a look at what "server-side rendering" means in this case, how it works with the browser and some of the benefits. It then talks about the rendering process and some of the tradeoffs between it and just using Javascript on the frontend. From there the post gets to the examples of the actual rendering process. If creates a simple Vue.js application that outputs a "Hello, world!" template. It then includes the code to use the packages (that, in turn, use the V8JS package) to render the Javascript and output the result.

tagged: serverside render javascript tutorial package spatie v8js

Link: https://sebastiandedeyne.com/posts/2018/server-side-rendering-javascript-from-php

Freek Van der Herten:
What Laravel 5.5 means for our packages
Aug 31, 2017 @ 14:33:51

In a new post to his site Freek Van der Herten covers how some of the changes that happened in Laravel's v5.5 release would impact the packages Spatie shares, some of the more popular PHP packages with a wide range of functionality.

At Spatie we’ve released a auto-discovery facades functionality, LTS releases and how some new functionality replaces (retires) packages Spatie had already released.

Laravel 5.5 is probably the best release yet. But, in all honesty, I think that of every Laravel release. My recommendation is to get your apps upgraded to this version as soon as possible. The reward is that you can make use of all L5.5’s new features and the latest major versions of our packages.
tagged: spatie packages laravel55 impact replace functionality

Link: https://murze.be/2017/08/laravel-5-5-means-packages/

Scotch.io:
User Authorization in Laravel 5.4 with Spatie Laravel-Permission
May 16, 2017 @ 16:28:09

On the Scotch.io site a new tutorial has been posted showing you how to use the Laravel-permission package (from Spatie) to more easily handle permission setup and validation in a Laravel application.

When building an application, we often need to set up an access control list (ACL). An ACL specifies the level of permission granted to a user of an application. For example a user John may have the permission to read and write to a resource while another user Smith may have the permission only to read the resource.

In this tutorial, I will teach you how to add access control to a Laravel app using Laravel-permission package. For this tutorial we will build a simple blog application where users can be assigned different levels of permission.

The tutorial then walks though the installation of the package and some of the new tables it adds to the database when you run the included migrations. It then talks about some of the methods that can be used, both on the backend and in Blade templates, to evaluate if the current user has the roles required. Next up is the creation of the controllers to handle the basic CRUD tasks and working with the blog posts and views to set up the permissions and roles. Finally the tutorial shows the code required to evaluate the roles and permissions of the user and an example of middleware that performs a pre-check to see if a user even has access to manage various pieces of the application.

tagged: tutorial spatie permission role package introduction blog acl ui interface

Link: https://scotch.io/tutorials/user-authorization-in-laravel-54-with-spatie-laravel-permission

QCode.in:
Easy roles and permissions in Laravel 5.4
May 03, 2017 @ 17:06:41

On the QCode.in site Saqueib Ansari has written up a tutorial showing how to use a package in Laravel applications to manage roles and permissions easily. This package, spatie/laravel-permission, compliments the current Laravel roles/permissions handling with a few handy features that make management and evaluation simpler.

Although laravel comes with Policies to handle the authorization but I wanted to have an option to just create permissions in the database which we can manage by a UI in the admin panel, pretty standard. we can implement our own role and permission from scratch but I am going to use [spatie/laravel-permission](https://github.com/spatie/laravel-permission) package for this. This package was inspired by Jeffrey ways screencast and it’s very well maintained and very easy to use. It has everything we need and plays very well with Laravel Gate and Policies implementations.

He walks through the creation of a new Laravel application, running the auth:make to generate the authentication functionality and adding the spatie/laravel-permission package to the service provider. He creates several models for permissions and roles and updates the User model with a new trait. Once the migrations are run, he creates a default permission set. Then it's on to the code for the endpoints to work with roles (including syncing them with permissions). He then moves over to the views, showing how to use the can helper to determine if a user has access, creating an Authorizable trait and an AuthorizationException handler. Finally the tutorial wraps up with the roles and permissions management functionality complete with code and screenshots of the result.

tagged: laravel roles permissions tutorial package laravelpermission spatie management

Link: http://www.qcode.in/easy-roles-and-permissions-in-laravel-5-4


Trending Topics: