Installation
About Dreamfork
DreamFork is a lightweight web application framework designed to facilitate the development of web applications. Drawing inspiration from Laravel, it strives to incorporate various Laravel features while maintaining a significantly smaller size. This emphasis on a streamlined codebase contributes to DreamFork's faster performance compared to Laravel, albeit with some trade-offs in terms of security.
Developed by a solo developer, DreamFork aims to provide a Laravel-like toolset while offering a smaller footprint. It is essential to note that, due to its smaller development team and evolving nature, DreamFork may have some limitations and imperfections.
The framework serves as a starting point for developers familiar with Laravel, offering a structured foundation. Leveraging straightforward mechanisms like dependency injection and service isolation, DreamFork prioritizes modularity and provides intuitive ways to extend and enhance projects. This approach allows developers to build upon a familiar Laravel base while enjoying the benefits of a more lightweight and performance-oriented framework.
This documentation serves as a comprehensive guide to help developers grasp the fundamental workings of the DreamFork framework. It is intended to offer insights into the core concepts and functionalities, providing a clear understanding of how to leverage DreamFork in your projects.
When to use Dreamfork
DreamFork is primarily designed for projects related to personal learning or non-critical applications where flawless and secure operation is not an absolute necessity. It is well-suited for endeavors such as personal learning projects, experimental applications, or projects that do not demand the robustness required for critical systems like e-commerce platforms or subscription-based websites.
Learning PHP Frameworks:
DreamFork provides an excellent entry point for individuals embarking on their journey with PHP frameworks. Its smaller and more straightforward architecture offers a less overwhelming experience compared to larger frameworks like Laravel or Symfony. This makes it particularly suitable for those looking to familiarize themselves with the structural and organizational aspects commonly found in prominent PHP frameworks.
Simplified Projects:
For developers aiming to create straightforward projects without compromising on the power and versatility of established PHP frameworks, DreamFork is an apt choice. It strikes a balance between simplicity and functionality, making it suitable for small to medium-sized applications.
Exploration and Experimentation:
DreamFork is well-suited for exploration and experimentation, allowing developers to try out ideas and implement features in a more lightweight environment. Its modular structure encourages developers to extend and modify the framework to suit their specific needs.
Creating A Dreamfork Project
Before initiating your first DreamFork project, ensure that your local machine is equipped with PHP and Composer. Additionally, having Git installed is a prerequisite. We also recommend installing Node and NPM for enhanced capabilities.
After successfully installing PHP and Composer, follow these steps to create a new DreamFork project by cloning the repository using the terminal:
git clone https://github.com/PiciuU/DreamFork-PHP-Framework.git
Once the project has been created, navigate to the project folder and create a copy of .env.example, renaming it to .env. Additionally, remove the .git folder, which represents the Git repository of the framework:
mv DreamFork-PHP-Framework example-app
cd example-app
cp .env.example .env
rmdir /s .git
Next, install the project dependencies using Composer:
composer install
With the project dependencies installed, you can launch the development server. While Laragon is recommended, you can also use PHP's built-in web server:
php -S localhost:8000 -t public/
Once the development server is running, access your application in the web browser at http://localhost:8000 or at the path provided by Laragon or your chosen development environment.
Initial Configuration
All configuration files for the DreamFork framework are centralized in the config directory. Each configuration option is thoroughly documented, providing transparency on the available settings.
DreamFork is designed to require minimal additional configuration, allowing developers to start coding immediately. However, it's advisable to review the config/app.php file and its documentation. This file encompasses various options, including settings for timezone and locale, which you may consider adjusting to align with your application's specific requirements.
Environment Based Configuration
Given that various configuration options in DreamFork may differ based on whether your application is running locally or on a production web server, crucial configuration values are specified in the .env file located at the root of your application.
It is imperative not to include the .env file in your application's source control. This precaution is taken because each developer or server utilizing your application may require a distinct environment configuration. Moreover, committing the .env file would pose a security risk in the event of unauthorized access to your source control repository, potentially exposing sensitive credentials.
Databases & Migrations
If your application needs to store data in a database, DreamFork currently supports only MySQL. By default, the basic database connection settings are defined in the .env file, and you can customize them according to your needs.
If your project involves authentication mechanisms, you need to migrate the relevant tables to your database. These tables are located in the database/migrations folder. Currently, the framework doesn't provide automatic migrations, so you need to perform them manually. Each migration file contains a prepared SQL command to create the required table. Execute these commands to set up the necessary tables in your database.
"Personal Access Tokens" table structure must precisely match the one defined in the migration file. The framework currently does not support modifications to this table.
Directory Configuration
Dreamfork should always be served from the root of the "web directory" configured for your web server. Avoid attempting to serve a Dreamfork application from a subdirectory within the "web directory" as this may inadvertently expose sensitive files present within your application.
Next steps
Now that you have created your Dreamfork project, you may be wondering about the next steps in your learning journey. First and foremost, we strongly recommend gaining familiarity with the inner workings of Dreamfork by exploring the following documentation:
Additionally, the path you choose for utilizing Dreamfork will influence the subsequent steps in your journey. There are various approaches to leveraging Dreamfork, and we will delve into two primary use cases for the framework below.
Dreamfork The Full Stack Framework
Dreamfork can serve as a full-stack framework, where it handles routing requests to your application and facilitates rendering your frontend using the Vision template engine. Utilizing Dreamfork in this manner is possible; however, it is not recommended due to the absence of certain mechanisms, such as session handling.
It's also important to note that, as of now, the template engine is not as advanced, limiting its ability to create more sophisticated views. Due to this limitation, the second approach is generally recommended for a more comprehensive and feature-rich experience.
Dreamfork The Api Backend
Dreamfork is ideally suited for use as an API backend, with the frontend built on technologies like Vue or React. In this approach, you can leverage Dreamfork to handle authentication and manage data storage and retrieval for your application.
If this how you plan to use Dreamfork, it's recommended to explore our documentation on routing, tokenization, and ORM mechanisms for effective database management.