技術情報

Log Viewer for Laravel

Log Viewer supports multiple logs. You can view individual, daily, and period records. You can also use a package configuration file to customize the logs your application collects.

The Log Viewer app provides beautiful, formatted, collapsible, expandable, and searchable logs instead of analyzing plain text logs.

https://twitter.com/arukomp/status/1560914306815901697?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1560914306815901697%7Ctwgr%5Ebf7f4d7c6e854016490cea9415333ba721f53a0f%7Ctwcon%5Es1_c10&ref_url=https%3A%2F%2Flaravel-news.com%2Fbeautiful-log-viewer-for-laravel

  • Here are the main features of this package:
  • Link directly to logs
  • Searchable and filterable by severity
  • Download and remove logs via the UI
  • Short stack traces to remove trace cruft from logs
  • Configurable log viewer
  • Built with Alpine.js, Tailwind, and Laravel
  • Sort by oldest or newest logs
  • Light and Dark mode

If you want to check more on this Log Viewer package, please read this.

Yuuma



[Laravel] カスタムバリデーションの追加

今回はLaravel標準のバリデーション機能ではカバーできない特別なバリデーションを追加したい場合に有効なバリデーション方法を紹介したいと思います。

続きを読む

Websockets and Server Sent Events

Today, I would like to share about WebSockets and Server Sent Event (SSE). Both WebSockets and Server Sent Events are realtime push-based communication methods. Let’s explore at them.

WebSockets

WebSockets is a technology that enables bidirectional real-time interactive communication between a client and a server. WebSockets use the WebSocket protocol for communication.

Advantages

– WebSockets allow realtime bidirectional communication.

– WebSockets are supported in most of the latest browsers today.

– WebSockets don’t use XMLHttpRequest. So unnecessary data loads to the server are reduced.

– Binary data and UTF-8 text formats can be sent with WebSockets.

Disadvantages

WebSockets need TCP connection to work and don’t entirely need HTTP. They just need HTTP to initiate the connection for establishing standalone TCP connection that is used with WebSocket protocol. So some of HTTP functionality cannot be taken in WebSockets. The following are disadvantages of Websockets.

– No compression support

– Not support HTTP/2 mutiplexing

– WebSockets are not supported in old version browsers

– Setting up WebSockets is not simple and takes some time.

– May be issues for some firewalls with packet monitoring

Server Sent Events

SSE (Server-Sent Events) is a technology that allows a client browser to receive automatic updates from a server over a standard HTTP connection but not bidirectional. SSE use the JavaScript EventSource API.

Advantages

– Since SSE uses HTTP, it takes some advantages of HTTP functionality.

– SSE is easy to use and faster to setup.

– SSE will not cause problems with packet monitoring.

Disadvantages

– SSE does not allow bidirectional communication or data transmission.

– SSE can only send UTF-8 data and not binary data.

– SSE has restrictions about maximum number of open conenctions.

These are advantages and disadvantages of WebSockets and Server Sent Event. The case of choosing one of them depends on which solutions you want to solve and what your system needs.

This is all for now. Hope you enjoy that.

By Asahi



Introduction to Cloudflare

Cloudflare is one of the world’s largest networks. Today, businesses, nonprofits, bloggers, and anyone with an online presence can benefit from faster, more secure websites with the help of Cloudflare.

There are millions of internet properties on Cloudflare and the network is growing by tens of thousands every day. Cloudflare powers internet requests for millions of websites, serving an average of 36 million HTTP requests per second.

Cloudflare network map
Credit: Cloudflare

In the early days of the Internet, when you wanted to load a website, your computer sent a request to a server, and the server returned the requested web page.

If the server is receiving too many requests at once, its servers could be overwhelmed and crash, stalling anyone trying to access the resources they host.

This made it difficult for the owners to provide fast, secure, and reliable content. Cloudflare was created to help mitigate these issues and provide users with resources to keep their sites, apps, and blogs safe and efficient. This is done using a powerful perimeter network that delivers content and other services as close as possible so you can access information as quickly as possible.

Cloudflare also provides security by protecting Internet properties from malicious activity such as DDoS attacks, malicious bots, and other malicious intrusions. It also offers rich features like his SSL and content delivery to all websites in its network.

Also, the website owner can easily embed the app into her website without being a developer.

If you’re a developer, you can run your Javascript code in a powerful perimeter network, keeping you as close to your users as possible. This eliminates latency and improves user experience.

Yuuma



Laravel Tips

一度に1つのレコードをseedingすると、DBが遅くなる可能性があります。より良い方法は、PHPでレコードを大量に作成し、それをChunkしてシードするで1万queryから5queryにする方法
use App\Models\User;

User::factory(10000)->create();

上記のコードを見ると、Laravelは1ユーザーを作成し、1queryでデータベースに挿入しています。これを1万回繰り返しています。そうすると、パフォーマンスにとって悪いことで、DBを遅くしてしまいます。しかし、これを簡単に解決することができます!

$records = User::factory()->count(10000)->make();

$records->chunk(2000)->each(function($chunk) {
     User::insert($chunk->toArray());
});

上のコードでは、メモリ(PHP)上に10,000のユーザーレコードが作成されています。 次に、これを2,000レコードのチャンクに分割して配列に変換し、クエリの数を10,000から5つにします!

ということで、今回はこれで終わります。

金曜担当 – Ami




アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム