astra-techno / data-forge
A Laravel package for creating modular SQL, Entity, and Task-based backends.
Requires
- php: ^8.0
- laravel/framework: ^8.0|^9.0|^10.0|^11.0|^12.0
README
DataForge is a robust Laravel-based framework designed to streamline SQL query management, entity-based data handling, and modular task workflows. It helps developers build scalable, maintainable, and high-performance backend solutions for web applications.
Key Features
- Dynamic SQL Query Builder: Write clean and reusable SQL queries using innovative features like
filterOptional
andfilterAnyOneRequired
. - Entity Management: Encapsulate business logic with lazy-loading, inter-entity connectivity, and attribute grouping.
- Modular Task Workflows: Handle complex backend logic with reusable task classes.
- Prebuilt API Endpoints: Ready-to-use endpoints for fetching lists, single items, field values, and more.
- Scalability & Flexibility: Perfect for applications ranging from startups to enterprise-grade systems.
Installation
Install the package via Composer:
composer require astra-techno/data-forge
Getting Started
1. Publish Configuration and Setup
After installation, publish the configuration file and setup the directory structure:
php artisan vendor:publish --provider="AstraTech\DataForge\DataForgeServiceProvider"
This will create the app/DataForge
directory, which includes Sql
, Entity
, and Task
subdirectories.
2. Create a SQL Class
Define your SQL queries in a dedicated class:
namespace App\DataForge\Sql; class Product extends \DataForge\Sql { public function list(&$data) { $query = Query('ProductList'); $query->select('list', 'p.id, p.name, p.price, p.stock, c.name AS category'); $query->from('products AS p'); $query->inner('categories AS c ON p.category_id = c.id'); $query->filterOptional('p.name LIKE {%request.keyword%}'); $query->group('p.id'); $query->order('{request.sort}', '{request.order}'); return $query; } }
3. Create an Entity Class
Define the business logic for your module:
namespace App\DataForge\Entity; class Product { use \DataForge\Entity; function init($id) { return \Sql('Product:list', ['id' => $id, 'select' => 'entity'])->fetchRow(); } function getCategory() { return \DataForge::getCategory($this->category_id); } }
4. Use API Endpoints
Leverage prebuilt endpoints for data retrieval and task execution:
-
Fetch a list of products:
GET /api/list/Product:list?keyword=shoes&pageNo=1&limit=10
-
Retrieve a product entity:
GET /api/entity/Product/1
-
Execute a task:
POST /api/Task/ProductTask/detail
Documentation
Explore the full documentation, examples, and demo at: 🌐 DataForge Documentation
Contributing
We welcome contributions to improve DataForge. Follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push to your fork.
- Submit a pull request.
License
DataForge is open-source software licensed under the MIT License. See the LICENSE file for more details.
Connect with Us
- Official Site: data-forge.tech
- LinkedIn: Follow Us
- Twitter: @DataForgeTech
Support
If you encounter any issues or have questions, feel free to reach out through the GitHub Issues or our support page.
Build powerful backends with DataForge!