Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

database posts

  • By Oluyemi Olususi
    Laravelアプリケーションでリポジトリパターンを使う方法 Laravelアプリケーションでリポジトリパターンを使う方法

    この記事はOluyemi Olususiこちらで公開した記事(英語)を日本語化したものです。

    リポジトリは、ドメインとデータマッピングレイヤー間の抽象化レイヤーとして定義できます。これにより、コレクション的なインターフェイスを通じてドメインオブジェクトにアクセスして両者の仲介手段を提供します。

    LaravelSymfonyなど、最新のPHPフレームワークは、オブジェクト関係マッピング(ORM)を介してデータベースを操作します。SymfonyのデフォルトORMはDoctrineで、LaravelはEloquentを使用します。

    ともに、データベース操作のために異なるアプローチがとられます。Eloquentの場合、データベーステーブルごとにモデルが生成され、操作の基盤が形成されます。一方、Doctrineはリポジトリパターンを使用します。各エンティティには対応するリポジトリがあり、データベースを操作するヘルパー関数が格納されています。Laravelは標準でこの機能は提供していませんが、Laravelプロジェクトでリポジトリパターンを使用することは可能です。

    リポジトリパターンを使う主なメリットは、依存性逆転の原則(具体化でなく抽象化コード)を使用できる点です。これにより、例えば後でEloquentがサポートしないデータソースに変更した場合などに、変更の影響を受けにくいコードを作成できます。

    データベース関連のロジックを一箇所で管理することにより、コードの構成を整理したり、重複を避けることにもつながります。このようなメリットは小規模のプロジェクトではすぐに …

    Read More
  • By Ijeoma Nelson
    How to Create a RESTful API in PHP With SlimPHP 4 and MySQL How to Create a Restful API With SlimPHP 4 and MySQL

    For those times when all you need is a simple solution that enables you to write quick, yet powerful applications, Slim is a great contender amongst the myriad of available PHP frameworks.

    At its core, Slim is a microframework designed to receive HTTP requests, route the requests to the relevant controllers, and return the corresponding HTTP responses.

    Slim’s minimalist environment makes it ideal for the development of both microservices and APIs that consume, repurpose, or publish data.

    In this tutorial, you’re going to learn how to create a RESTful API using Slim 4, PHP, and MySQL.

    Prerequisites

    To complete this tutorial you will need the following:

    • PHP 7.4. Ideally version 8.1.
    • Composer installed globally.
    • MySQL 8.
    • Postman.

    Let's create the API!

    To begin, you need to create the project’s root directory, named customers-api. You can do this in your editor/IDE or by running the following commands on a …

    Read More
  • By Oluyemi Olususi
    How to Use the Repository Pattern in a Laravel Application How to Use the Repository Pattern in a Laravel Application Header

    A repository can be defined as a layer of abstraction between the domain and data mapping layers, one that provides an avenue of mediation between both, via a collection-like interface for accessing domain objects.

    Modern PHP frameworks, such as Laravel and Symfony, interact with databases via Object-relational mappers (ORMs); Symfony uses Doctrine as its default ORM and Laravel uses Eloquent.

    Both take different approaches in how database interaction works. With Eloquent, Models are generated for each database table, forming the basis of interaction. Doctrine, however, uses the Repository pattern where each Entity has a corresponding repository containing helper functions to interact with the database. While Laravel doesn't provide this functionality out of the box, it is possible to use the Repository pattern in Laravel projects.

    A key benefit of the Repository pattern is that it allows us to use the Principle of Dependency Inversion (or code to …

    Read More
  • By Luís Leão
    Crie APIs GraphQL em Django com Graphene Crie APIs GraphQL em Django com Graphene

    GraphQL é uma linguagem de manipulação e consulta de dados de código aberto para APIs em tempo de execução para atender a consultas com dados existentes. Essa linguagem foi desenvolvida internamente pelo Facebook em 2012 antes de ser lançada publicamente em 2015. Ela permite que os clientes definam a estrutura dos dados solicitados, e a mesma estrutura dos dados é retornada do servidor, evitando assim que dados desnecessários sejam retornados.

    O GraphQL tem três operações principais: Consultas para leitura de dados, Mutações para gravação de dados e Assinaturas para recebimento automático de atualizações de dados em tempo real. Um servidor GraphQL fornece aos clientes um esquema predefinido, um modelo dos dados que podem ser solicitados. O esquema serve como um terreno comum entre o cliente e o servidor.

    Neste tutorial, usaremos Graphene, um framework GraphQL para Python, para criar uma API Django que usa consultas e mutações.

    Requisitos do …

    Read More
  • By Diane Phan
    How to Store and Display Media Files Using Python and Amazon S3 Buckets header - How to Store and Display Media Files Using Python and Amazon S3 Buckets

    It can be difficult navigating external platforms and storing data to the cloud. However, this is part of the process when scaling a small application that might rely on in-house databases such as SQLite3.

    Amazon Simple Storage Service (Amazon S3) offers fast and inexpensive storage solutions for any project that needs scaling. The Python code interacts with the S3 buckets to store and retrieve objects with flexible permission changing settings.

    Follow along in this tutorial to learn more about how a Python and Flask web application can use Amazon S3's technologies to store media files and display them on a public site.

    Tutorial Requirements

    In order to build this project, you will need to have the following items ready:

    • Python 3.6 or newer. If your operating system does not provide a Python interpreter, you can go to python.org to download an installer.
    • Create a free account or sign in …
    Read More
  • By Luís Leão
    Como usar o Google Sheets como um banco de dados para seu app PHP Como usar o Google Sheets como um banco de dados para seu app PHP

    Introdução

    Há doze anos, o Google teve, na minha opinião, a ideia ambiciosa de lançar um produto que estaria em concorrência direta com o Excel. Desde então, o Google Sheets ganhou popularidade e tornou-se muito mais do que apenas uma planilha. Por ser um aplicativo on-line, é muito mais fácil integrá-lo às suas diferentes ferramentas on-line. Neste tutorial, testaremos a flexibilidade do Sheets buscando dados da API do Order Desk, atualizando uma planilha do Google e enviando uma confirmação da Twilio via SMS. Usaremos o Order Desk para simular um sistema de atendimento de uma loja virtual, que faz o backup de seus dados em uma planilha do Google.

    Requisitos do tutorial

    Para este tutorial, você precisará do seguinte:

    Configuração do ambiente de desenvolvimento

    Para começar, …

    Read More
  • By Diane Phan
    How to Store Multimedia Files in a SQLite3 Database with Python header - How to Store Multimedia Files in a SQLite3 Database with Python

    If you're a developer who is building out a website that allows users to upload image files for reasons such as updating a profile picture, sharing images with other users, or utilizing other multimedia files, you will find yourself wondering, "what's the safest way to save their data?".

    You could store the files directly in the server’s file system, integrate with APIs from cloud storage platforms, or you can learn how to store the information in your database!

    In this tutorial, you will learn about blob (binary large object) data and why you need to convert your multimedia files to binary objects in order to store them properly in a database. Then you will learn how to retrieve the blobs and convert them back into regular files for use by your application.

    Let's get started!

    Tutorial requirements

    • Python 3.6 or newer. If your operating system does not provide a Python …
    Read More
  • By Adeyemi Atoyegbe
    Building GraphQL APIs in Django with Graphene Building GraphQL APIs in Django with Graphene

    GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. It was developed internally by Facebook in 2012 before being publicly released in 2015. It allows clients to define the structure of the data required, and the same structure of the data is returned from the server, therefore preventing unnecessary data from being returned.

    GraphQL has three primary operations: Queries for reading data, Mutations for writing data, and Subscriptions for automatically receiving real-time data updates. A GraphQL server provides clients with a predefined schema – a model of the data that can be requested. The schema serves as common ground between the client and the server.

    In this tutorial we will use Graphene, a GraphQL framework for Python, to build a Django API that uses queries and mutations.

    Tutorial Requirements

    To follow along with this tutorial you should have …

    Read More
  • By Alex Kiura
    Build a GraphQL API with Python, Flask and Ariadne Build a GraphQL API with Python, Flask and Ariadne

    You have probably come across the term GraphQL but do you know what is it? Rest easy (pun not intended), as you will learn about it shortly.

    GraphQL is a query language for APIs and a server-side runtime that allows clients to request only the data that they need from APIs. GraphQL is meant to be a more efficient and flexible alternative to REST.

    GraphQL was developed and used internally at Facebook and was open-sourced in 2015. It has since gained popularity with more and more developers and companies jumping on the GraphQL bandwagon, building supporting tools and GraphQL APIs. One of the most popular is the Github GraphQL API. GraphQL is language agnostic which means that we can build GraphQL APIs in Python, JavaScript, Java, Scala and many more programming languages.

    GraphQL vs. REST

    With REST, we model our API as resources, provide endpoints to access particular …

    Read More
  • By Diane Phan
    How to Connect a Twilio WhatsApp Python Project to SQLite3 header - How to Connect a Twilio WhatsApp Python Project to SQLite3

    Once you get started with the Twilio WhatsApp API, you'll realize that it's really fun and easy to get carried away coming up with ideas for new projects. But what happens when one of your projects takes off and you want to scale up?

    If your project requires storing message data, then building a database might be one of the first steps in expanding your project.

    In this tutorial, you will learn how to store Twilio WhatsApp data in a secure database that allows you to insert, update, and delete data as you please.

    Tutorial requirements

    • Python 3.6 or newer. If your operating system does not provide a Python interpreter, you can go to python.org to download an installer.
    • SQLite3 in order to open the SQLite shell and make executable scripts.
    • Some prior knowledge in SQL logic or a willingness to learn.

    Choose a database

    If this is your first …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.