Skip to main content

Posts

Showing posts from May, 2021

Laravel Forge Setup on Umami self-hosted analytics | Laravelnote

  Many of us are loooking to move away from Google Analytics where possible. Reasons for doing so include: Data privacy concerns Avoiding cookie warnings Seeking a simpler UI to share with clients/team While looking into alternatives you'll find a range of paid, privacy-focussed SaaS analytics products, as well as some self hosted open source options (some of which are shared by companies who also offer a hosted paid service). I wanted a self hosted option and before settling on Umami.js I also checked: Ackee Plausible (self-hosted, SaaS available) Pirsch (self-hosted, SaaS available) For all I know, these might be great - but I didn't get to a feature comparison or to try any of them out. I went with Umami.js simply because of how I wanted to install it on this occasion: on an Ubuntu VM, with Postgress/MySQL, and without using docker. One nice feature of Umami.js is easily sharing a public dashboard for a website, you can take a look at their own public dashboard (pictured bel

PHP routing library for in laravel8 fast API development 2021

What it is? | Laravelnote PHP Routing is a custom written routing library that was inspired by the  Slim framework . It was written as a small and lightweight alternative to it as I needed to use something with as little overhead as possible . The first version of the library was consisting of a single PHP class that was able to handle static and some basic dynamic routes and had a semi working support for adding and using middlewares. At first that was more than enough for my use case and the library was left at that, but recently I started rewriting one of my personal projects  Did You Buy It?  live on my  Twitch  channel and decided I wanted to use PHP for it, as the original API was developed using Node and Express. What does it do? | Laravelnote Exaxmple on how to add your own routes: $routes = new Routes ; $routes -> add ( '/' , function () { echo "Hello world" ; }, Routes :: GET ); // If the request method is not specified the GET method is used

Faster Eloquent Chunking in Laravel users best news for devlopers | Laravelnote

As your applications scale, processing large amounts of database records with Laravel Eloquent can become increasingly difficult. Resulting in out of memory exceptions and overall slowing down your application. Why is that? When fetching results from the database you are in turn pulling that data into memory. Take this snippet of code for instance Post :: all () -> each ( function ( $post ) { // ... }); Which results in the following query, loading all records in the posts table into memory select * from posts ; Typically for tables with a small number of records, this is absolutely acceptable. However, as you accumulate tens of thousands of posts you will eventually begin hitting memory resource constraints of your webserver. Chunking | Laravelnote A common approach in Laravel is to use Eloquent's (via  BuildsQuery )  chunk()  method which fetches a fixed amount of records breaking a larger set into more consumable chunks. Post :: chunk ( 1000 , function ( $post

Laravel8 in Serializes Models trait | laravelnote

This article was originally posted, with additional formatting, on my personal blog at laravel serializes model Background  When dispatching an object onto the queue, behind the scenes Laravel is recursively serializing the object and all of its properties into a string representation that is then written to the queue. There it awaits a queue worker to retrieve it from the queue and unserialize it back into a PHP object (Phew!). Problem When complicated objects are serialized, their string representations can be atrociously long, taking up unnecessary resources both on the queue and application servers. Solution Because of this, Laravel offers a trait called SerializesModels which, when added to an object, finds any properties of type Model or Eloquent\Collection during serialization and replaces them with a plain-old-PHP-object (POPO) known as a ModelIdentifier. These identifier objects represent the original properties Model type and ID, or IDs in the case of an Eloquent\Collection,

Laravelnote | Laravel8 Eventmie MultiOrganization Online Event Tickete Platform in Laravel8

Eventmie Pro, the event ticketing platform, is 100% secure and production-ready to be installed on your server. It can be used as a fresh new event ticketing website or can be integrated into an existing Laravel website. And with Eventmie Pro, you can handle the entire process of selling events tickets from scratch to finish, providing value to organizers, customers, and the website owner (Admin). Q. Are you tired of paying unnecessary commissions on every ticket sale of your online or offline events? Q. Do you want to stop paying monthly subscriptions to sell your events on someone else's platform? Q. Are you planning to launch your own event ticket selling platform on your domain? Q. And are you worried about no offline events and no event business in general due to COVID-19? Q. Are you still looking for an appropriate event management website solution that is affordable and fits your needs? Then you should give Eventmie Pro a try. Repetitive Event Simple event Why do you need Ev

Laravel in Tailwind CSS? How it work on laravel8

Tailwind v2.1 was just released with a new JIT Engine, Filter and Backdrop-filter Utilities, and more. Let's take a look at some of the new features. JIT Engine | Laravelnote A few weeks ago, the Tailwind team released a package they were using to expiriment with a just-in-time compiler for Tailwind. With the release of Tailwind v2.1, the JIT compiler is included in Tailwind core. Just add mode: 'jit' to your Tailwind config file and configure the purge property to scan your markup. // tailwind.config.js module.exports = {   mode: 'jit',   purge: [     // ...   ],   // ... } Filter and Backdrop-filter Utilities filter and backdrop-filter utilities have been added. These additions have a composable API similar to the transform utiltiies in Tailwind. Apply the filter (or backdrop-filter) class and then you combine utilities for blur, brightness, contrast, drop-shadow, and other CSS filter properties. Check out the possibilities in the Tailwind docs. <div class=&quo

Create Controllers with a Custom Stub in Laravel 8.36

The Laravel team released 8.36 with a custom stub option when creating controllers, a useCurrentOnUpdate method for blueprint datetime columns in MySQL, a dispatch_sync() helper function, and the latest changes in the 8.x branch: Support useCurrentOnUpdate for MySQL Datetime Columns Tim Martin contributed support for useCurrentOnUpdate for MySQL DATETIME column types: This allows using DATETIME columns for metadata like created_at and updated_at more effectively. Since TIMESTAMP columns in MySQL suffer from the Year 2038 Problem , using DATETIME columns is preferred in some applications. Here's an example from the tests: $blueprint = new Blueprint('users'); $blueprint->dateTime('foo')->useCurrentOnUpdate(); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertCount(1, $statements); $this->assertSame('alter table `users` add `foo` datetime on update CURRENT_TIMESTAMP not null', $statements[0]); Queue

Data Transfer Object V3 Modernizes DTOs With PHP 8 Features

Spatie's Data Transfer Object (DTO) package makes constructing objects from arrays a breeze, giving you confidence in the data contained therein. I've been a fan of this package since learning about the initial V1 release, and I hope you'll consider this package for passing around data in your application. The DTO package just released V3 with all of the PHP 8 goodies we've only dreamed of up to this point. For those just starting to use or consider PHP 8 in your projects, the source code of the V3 DTO package is an excellent resource with real-world examples of helpful PHP 8 features. I want to congratulate the principal author Brent Roose and Spatie for moving forward with this excellent package with the features in the V3 release. Here are some of the main features taken from the readme available in V3: Named arguments Value Casts - convert properties typed as a DTO from array data to the DTO instance automatically Custom Casts - you can build your custom caster clas

Laravel v7.12.0 released

Laravel v7.12.0 is released in 2020/05/19, here are the changes we`ve merged into this release. v7.12.0 (2020-05-19) Added Added Illuminate\Http\Middleware\TrustHosts (9229264) Added ability to skip middleware from resource routes (#32891) Fixed Fixed Queued Mail MessageSent Listener With Attachments (#32795) Added error clearing before sending in Illuminate\Mail\Mailer::sendSwiftMessage() (#32799) Avoid foundation function call in the auth component (#32805) Fixed inferred table reference for Illuminate\Database\Schema\ForeignIdColumnDefinition::constrained() (#32847) Fixed wrong component generation (73060db) Fixed bug with request rebind and url defaults in Illuminate\Routing\UrlGenerator (6ad92bf) Fixed Illuminate\Cache\ArrayStore::increment() bug that changes expiration to forever (#32875) Changed Dont cache non objects in Illuminate/Database/Eloquent/Concerns/HasAttributes::getClassCastableAttributeValue() (894fe22) Added explicit symfony/polyfill-php73 dependency (5796b1e) Set C

Laravel Parallel Testing Is Now Available in laravel8 | Laravelnote

 Parallel Testing | Laravelnote As such we know Laravel and PHP Unit execute your tests sequentially within a single process.  As such laravel check the single process doesn’t use multiple cores so that therefore, your test execution is seriously bottlenecked! we glad to say that Parallel Testing is now available in Laravel. You can use this Laravel version8.25 you may also use to laravel8 built-in test Artisan command to run your cmd to tests simultaneously across multiple processes to use significantly reduce the time required for to run the entire test suite. It is about sure that in laravel8 new on top of Paratest Laravel automatically use to handles creating and migrating a test for database for each parallel process. In The  Laravel8 for testing purpose goodies - such as Storage::fake - are ready for used in Parallel too. Laravel Provide Each all individual laravel8 version use test suite will receive a varying benefits from parallel testing. In The Laravel Tests are execution wa

What is HTTP client in laravel8 by laravenote 2021 | Laravelnote

Laravel provides an expressive, minimal API around the Guzzle HTTP client, allowing you to quickly make outgoing HTTP requests to communicate with other web applications. Laravel's wrapper around Guzzle is focused on its most common use cases and a wonderful developer experience. Before getting started, you should ensure that you have installed the Guzzle package as a dependency of your application. By default, Laravel automatically includes this dependency. However, if you have previously removed the package, you may install it again via Composer: composer require guzzlehttp/guzzle Making Requests To make requests, you may use the get, post, put, patch, and delete methods provided by the Http facade. First, let's examine how to make a basic GET request to another URL: use Illuminate\Support\Facades\Http; $response = Http::get('http://example.com'); The get method returns an instance of Illuminate\Http\Client\Response, which provides a variety of methods that may be use