アプリ関連ニュース

知っておいていただきたいこと – 3

今回も、Laravelの知っておいた方がいいとおもったことをいくつか紹介します。

Tip # Laravel #exclude

入力を受け付けると、そのデータを使ってモデルを作りたいと思うことがよくあります。
例えば、登録フォームはUserモデルを作成するために使われるでしょう。しかし、すべてのフィールドを検証する必要がある一方で、モデルを作成するためにすべてのフィールドを必要としないかもしれません。このような場合、「exclude」ルールを使用します。

class StoreRequest extends FormRequest
{
  public function rules(){
      return [
         'name'                    => 'required|string',
         'email_address'           => 'required|string|email',
         'terms_and_conditions'    => 'required|accepted|exclude',    
       ];
  }
}

exclude’ ルールを使用すると、Laravel は ‘terms_and_conditions’ フィールドが全てのバリデーションルールをパスすることを保証しますが、 ‘validate’ または ‘validated’ メソッドによって返されるわけではありません。これにより、DBに’terms_and_conditions’のカラムがないことを気にせずに、簡単にモデルを作ることができます。

class RegistrationController extends Controller 
{
     public function store(StoreRequest $request)
     {
        $playload = $request->validate(); //名とメールだけ
        $user = User::create($playload);
        Auth::login($user);
        return redirect()->route('dashboard');
     }
}

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

金曜担当 – Ami



Nodejsの特徴

NodeJSは、オープンソースのクロスプラットフォームツールで、基本的にブラウザ環境の外でJavaScriptが機能するための実行環境を構築するものです。非同期プログラミングを利用する。

基本的に、NodeJsはJavaScriptの機能の範囲を広げます。NodeJsは、コーディング言語とAPI、他の言語、およびいくつかの外部ライブラリとの統合を支援します。

クロスプラットフォームの互換性

NodeJSは、Windows、Unix、Linux、Mac OS X、モバイルプラットフォームなど、複数のプラットフォームに対応しています。正しいパッケージと一緒に、完全に自立した実行ファイルにバンドルすることができます。

V8エンジン

元々Chrome用に開発されたV8エンジンは、現在ではWebアプリ開発の目的に合うように改良されています。V8エンジンは、JavaScriptをC++の助けを借りて一般的な機械語コーディング言語に翻訳できる、最も優れたエンジンの一つです。したがって、V8エンジンは、最終的にサーバーやすべての機械語ベースの製品に役立つ。

シングルスレッド

Node.jsはシングルスレッドで動作します。これは、複数のクライアントからのリクエストを処理できる「シングルスレッド・イベント・ループ・モデル」アーキテクチャをベースにしています。メインのイベントループはシングルスレッドで実行されますが、バックグラウンドでは、イベントループに対応するためにNode APIの入出力操作は非同期(ノンブロッキング設計)であるため、入出力作業は別々のスレッドで実行されます。イベントループは、node.jsがすべてのノンブロッキング処理を実行できるようにするものです。

非同期

Node.jsはデフォルトで非同期です。つまり、ノンブロッキングで動作します。つまり、クライアントがサーバにリクエストすると、1つのスレッドがそのリクエストを処理し、リクエストがデータベースとのやりとりを伴うかどうかをチェックし、リクエストが処理され、サーバからクライアントに応答が返されます。このスレッドは次のリクエストを処理する準備ができています。

高いスケーラビリティ

Node.jsのアプリケーションは、非同期(ノンブロッキング)方式で動作するため、高いスケーラビリティがあります。Node.jsはシングルスレッドで動作し、1つのリクエストが到着すると、その処理を開始し、次のリクエストを処理できるようになります。また、応答が準備されると、それはクライアントに送り返されます。

ノードパッケージマネージャ(NPM)

おなじみ、Nodeパッケージマネージャは、Node JavaScript実行環境用のパッケージマネージャで、Node.jsインストーラの推奨機能です。これは世界最大のオンラインリポジトリです。また、私たちのプロジェクトのローカル依存関係の管理も行っています。

キャッシング

Node.jsは、キャッシュという点でかなり有利です。Node.jsはモジュールのキャッシュをサポートしています。Node.jsのモジュールが初めてリクエストされたとき、アプリケーションのメモリにキャッシュされます。キャッシュにより、アプリケーションはウェブページをより速くロードし、ユーザーに簡単に応答できるようになるので、コードを再実行する必要はありません。

高速データストリーミング

データが異なるストリームとして移動する場合、その処理には多くの時間が消費されます。そこで、NodeJSは、アップロード中のファイルを同時に処理することで、データ処理にかかる時間を短縮します。そのため、NodeJsは全体的にデータや動画のストリーミング速度を速めることができます。

By Tsuki



FlutterでPDFを出力

FlutterでPDFファイルを作成することができます。

続きを読む

A simple script to send email by SMTP in Python

Today, I would like to share about sending emails by SMTP with a simple python script. Let’s take a look.

To send smpt emails, we will need just one library smtplib that is a built-in python lib. Here is the code.

There are just simple 6 steps.

1. Connect to a SMTP server [line 3]

2. Sending the SMTP ‘Hello’ Message [line 4]

3. Starting TLS Encryption [line 5]

4. Logging in to the SMTP server [line 7]

5. Sending an Email [line 8]

6. Disconnecting from the SMTP server [line 11]

Note: To send with gmail SMTP, you will need to turn on ‘Less secure app access’ in your gmail account settings.

This is all for now. Hope you enjoy and can expand to further uses based on that.

By Asahi



Low-Code Development Technology

Low code is a software development approach that requires little or no coding to create applications and softwares.

Instead of using a complex programming language, you can use a visual interface with basic logic and drag-and-drop capabilities on your low-code development platform.

Users with no advanced coding or software writing skills can use these intuitive techniques to create software for a variety of purposes, including mobile and business application creation.

These platforms are gaining popularity as a quick and easy alternative to traditional software development. The low-code framework can be used by engineers and “citizen developers” (non-professional developers) to build applications.

Low-code development

Instead of traditional hand-coded computer programming, the low-code development framework provides a programming environment for building software applications through a graphical user interface and configuration.

The low-code authoring framework allows users to embed building blocks in workflows and applications. These building blocks abstract the code behind actions and commands, allowing to build business interfaces and applications without having to manually code them.

Drag and drop functionality is available on popular lowcode platforms. This is one of the most important and valuable features that facilitates the manufacturing process. The drag-and-drop convenience provided during app development supports both civil and technical developers.

Security

Insecure low-code tools, no matter how convenient and easy to use, are not a good solution. Before you start using the low-code development framework, make sure you have enough protection to protect the app you are building and the entire platform.

There are still many factors to talk about but let me wrap up here for today. I will talk a bit more in future.

Yuuma



アプリ関連ニュース

お問い合わせはこちら

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

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

お問い合わせフォーム