PHP Classes

UpMVC PHP CRUD Framework: Build CRUD Apps with JS Action Confirmations

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (26)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-11-21 (5 months ago) RSS 2.0 feedNot enough user ratingsTotal: 102 All time: 9,765 This week: 455Up
Version License PHP version Categories
upmvc-crud 1.1Freeware8.2HTML, PHP 5, Databases, Libraries, De...
Description 

Author

This package allows developers to build CRUD applications with JavaScript action confirmations.

It provides base controller, model, and view classes to let developers implement applications that implement CRUD (Create, Read, Update, and Delete) operations on data records stored in a database.

The base classes generate HTML and JavaScript to make dialog boxes appear to let users confirm important actions they can ask the application to perform.

Picture of Adrian M
  Performance   Level  
Name: Adrian M <contact>
Classes: 4 packages by
Country: Ireland Ireland

Example

<?php
/*
 * Copyright (c) 2023 BitsHost
 * All rights reserved.

 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

require_once 'vendor/autoload.php';

//error_reporting(1);
use MyApp\Controllers\UserController;
use
MyApp\Models\UserModel;
use
MyApp\Views\UserView;



$crudController = new UserController(new UserModel(), new UserView());
$crudController->renderHeader();
$crudController->handleRequest();
$crudController->renderFooter();
?>


Details

Building a Simple PHP CRUD Application with JavaScript Confirmation In this tutorial, we'll walk through the process of creating a basic PHP CRUD (Create, Read, Update, Delete) application. Additionally, we'll integrate a JavaScript confirmation dialog to ensure a user's intent before performing a delete operation.

Demo: https://upmvc.com/crud/

Prerequisites Before getting started, make sure you have the following:

A web server (e.g., Apache) installed on your machine. PHP installed. Basic knowledge of HTML, PHP, and JavaScript. Project Structure Here's the directory structure of our project:

<img width="314" alt="upMVC - fileStructure" src="https://github.com/BitsHost/UpMVC-CRUD/assets/23263143/6bda03c9-2e5d-4e1f-884e-0f0082090d13">

Step 1: Setting Up the Project Create the project directory structure as shown above. Set up your web server to point to the public directory.

Step 2: Creating the Database Use the provided data.sql file to create a simple users table in your MySQL database. Adjust the database configuration in src/Models/UserModel.php accordingly.

Step 3: Implementing CRUD Operations Create: Implement the logic for adding a new user in CrudController.php. Read: Fetch and display users in a paginated manner in CrudController.php and CrudView.php. Update: Implement the logic for updating user information in CrudController.php. Delete: Implement the logic for deleting a user in CrudController.php and add a confirmation dialog using JavaScript in script.js.

Step 4: Paginating the User List In CrudController.php and CrudView.php, add pagination to display a limited number of users per page.

Step 5: Making the Delete Confirmation Specific In script.js, modify the confirmDeletion function to respond only to buttons with a specific class (e.g., delete-button).

Conclusion Congratulations! You've successfully built a PHP CRUD application with JavaScript confirmation for delete operations. This project serves as a foundation that you can extend and enhance based on your specific requirements.

Feel free to customize the application further, add user authentication, and integrate more advanced features to meet the needs of your project.

Happy coding!


  UpMVC PHP CRUDExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Files folder imageconfig (3 files)
Files folder imagepublic (1 directory)
Files folder imagesrc (3 directories)
Files folder imagevendor (1 file, 1 directory)
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file fileStructure.txt Doc. Documentation
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file conf.php Class Class source
  Accessible without login Plain text file DbConnection.php Class Class source
  Accessible without login Plain text file sample.sql Data Auxiliary data

  Files folder image Files  /  public  
File Role Description
Files folder imageassets (2 directories)

  Files folder image Files  /  public  /  assets  
File Role Description
Files folder imagecss (1 file)
Files folder imagejs (1 file)

  Files folder image Files  /  public  /  assets  /  css  
File Role Description
  Accessible without login Plain text file styles.css Data Auxiliary data

  Files folder image Files  /  public  /  assets  /  js  
File Role Description
  Accessible without login Plain text file script.js Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageControllers (2 files)
Files folder imageModels (2 files)
Files folder imageViews (2 files)

  Files folder image Files  /  src  /  Controllers  
File Role Description
  Accessible without login Plain text file BaseController.php Class Class source
  Accessible without login Plain text file UserController.php Class Class source

  Files folder image Files  /  src  /  Models  
File Role Description
  Accessible without login Plain text file BaseModel.php Class Class source
  Accessible without login Plain text file UserModel.php Class Class source

  Files folder image Files  /  src  /  Views  
File Role Description
  Accessible without login Plain text file BaseView.php Class Class source
  Accessible without login Plain text file UserView.php Class Class source

  Files folder image Files  /  vendor  
File Role Description
Files folder imagecomposer (8 files)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script

  Files folder image Files  /  vendor  /  composer  
File Role Description
  Accessible without login Plain text file autoload_classmap.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_namespaces.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_psr4.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_real.php Class Class source
  Accessible without login Plain text file autoload_static.php Class Class source
  Accessible without login Plain text file ClassLoader.php Class Class source
  Accessible without login Plain text file LICENSE Lic. License text
  Accessible without login Plain text file platform_check.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:102
This week:0
All time:9,765
This week:455Up