An open API service indexing awesome lists of open source software.

https://github.com/s-damian/phoenix-crud-example

CRUD - Phoenix Framework / Elixir / MySQL / Tailwind
https://github.com/s-damian/phoenix-crud-example

crud elixir elixir-phoenix mariadb mysql phoenix phoenix-framework tailwindcss

Last synced: 9 months ago
JSON representation

CRUD - Phoenix Framework / Elixir / MySQL / Tailwind

Awesome Lists containing this project

README

          





# Example of CRUD with Phoenix 1.7 / Elixir

This example is made by [Stephen Damian](https://github.com/s-damian)

## Requirements

* Elixir >= 1.14
* Erlang >= 24

## Introduction

This is an example of CRUD with: **Phoenix Framework** / **MySQL** / **Tailwind CSS**

In this example, there is :

* An example of an articles controller (for an HTML resource).
* An example of a products controller (for LiveView).

## Configuration - Phoenix App

Clone github repository:

```
git clone git@github.com:s-damian/phoenix-crud-example.git
```

In terminal, position yourself in the ```phoenix-crud-example``` directory:

```
cd /your_path/phoenix-crud-example
```

In ```config/dev.exs```, configure your database credentials. (For security reasons: in a production context, you must use environment variables. You should never put database credentials directly in the versioned code).

Install dependencies:

```
mix deps.get
```

Create the database (MySQL / MariaDB):

```
mix ecto.create
```

Run migrations:

```
mix ecto.migrate
```

## You can run the server, and you can run these demo URLs

### Run the server

```
mix phx.server
```

Here is an example of Virtual Host (Reverse Proxy) with Nginx: [Nginx Vhost for Phoenix](https://github.com/s-damian/phoenix-crud-example/blob/main/_nginx/vhost-example.conf)

### Run demo URLs

#### For example of an articles controller (for an HTML resource)

* http://127.0.0.1:4000/articles

* http://127.0.0.1:4000/articles/new

#### For example of a products controller (for LiveView)

* http://127.0.0.1:4000/products

* http://127.0.0.1:4000/products/new

And you can **Create** / **Read** (listing or show a single article) / **Update** / **Delete** articles.