Skip to content

This project is a simple CRUD API built using the Flight PHP framework. It provides a basic structure to quickly set up a PHP application with CRUD operations and database connectivity.

License

Notifications You must be signed in to change notification settings

soheilkhaledabdi/php-crud-api-flight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP CRUD API with Flight Framework

Description

This project is a simple CRUD API built using the Flight PHP framework. It provides a basic structure to quickly set up a PHP application with CRUD operations and database connectivity.

Features

  • Lightweight and fast setup with Flight framework.
  • Basic CRUD (Create, Read, Update, Delete) operations.
  • Configurable database connection.
  • Suitable for development with Apache, Nginx, or PHP's built-in server.

Prerequisites

Before you begin, ensure you have the following installed on your machine:

  • PHP 7.4 or higher
  • A web server (Apache, Nginx, or PHP's built-in server)
  • Composer (for dependency management)
  • A MySQL or MariaDB database server

Installation

Follow these steps to set up the project:

  1. Clone the Repository:

    git clone https://github.com/soheilkhaledabdi/php-crud-api-flight.git
    cd php-crud-api-flight
  2. Install Dependencies:

    Install the Flight framework and other dependencies using Composer:

    composer install
  3. Configure the Database:

    Copy the .env.example file to .env:

    cp .env.example .env
    • Configure the Database: Update the .env file with your database credentials.
  4. Set Up a Web Server:

    You can use Apache, Nginx, or PHP’s built-in server to run the project. Choose one of the following options:

    • Using PHP’s Built-In Server:

      Navigate to the public directory and start the PHP server:

      cd public
      php -S localhost:8000

      Now, open your web browser and visit http://localhost:8000.

    • Using Apache or Nginx:

      Set the document root to the public directory of the project. Configure the server to point to public/index.php.

      For Apache, you might set up a virtual host like this:

      <VirtualHost *:80>
          ServerName yoursite.local
          DocumentRoot /path/to/php-crud-api-flight/public
          <Directory /path/to/php-crud-api-flight/public>
              AllowOverride All
              Require all granted
          </Directory>
      </VirtualHost>

      For Nginx, your server block might look like this:

      server {
          listen 80;
          server_name yoursite.local;
          root /path/to/php-crud-api-flight/public;
      
          index index.php index.html index.htm;
      
          location / {
              try_files $uri $uri/ /index.php?$query_string;
          }
      
          location ~ \.php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
          }
      }
  5. Testing the Application:

    Once your server is set up, navigate to the URL configured (e.g., http://localhost:8000 or http://yoursite.local) and test the CRUD functionality.

Validation Package

We use the php-smart-validator package for validation. You can find more information and the source code at the following link:

https://github.com/geekGroveOfficial/php-smart-validator

Contributing

If you wish to contribute to this project, please fork the repository, create a new branch for your feature or bug fix, and submit a pull request.

License

This project is open-source and available under the MIT License.

About

This project is a simple CRUD API built using the Flight PHP framework. It provides a basic structure to quickly set up a PHP application with CRUD operations and database connectivity.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages