Directory Structure
Introduction
The default directory structure of the Dreamfork application is crafted to provide a solid foundation for projects of different scopes. You have the freedom to organize your application according to your preferences, as Dreamfork places almost no restrictions on where any given class is located, as long as Composer can autoload the class.
The Root Directory
The App Directory
The app directory holds the fundamental code for your application, serving as the primary location for most of your application's classes.
The Bootstrap Directory
The bootstrap directory houses the app.php file, responsible for bootstrapping the framework. Generally, there is no need to make modifications to any files within this directory.
The Config Directory
The config directory, as the name implies, contains all the configuration files for your application. It's a good idea to go through these files and get to know the various options available to you.
The Database Directory
The database directory contains your database migrations.
The Framework Directory
The framework directory contains all the essential files that form the foundation of the framework. Changes to this directory should be made only when you intend to enhance the core functionality of the framework for your application. It serves as the backbone, and any modifications should be approached with caution, reserved for cases where you are extending the framework's core features to suit your application's needs.
The Public Directory
The public directory hosts the index.php file, serving as the entry point for all incoming requests to your application and configuring autoloading. Additionally, this directory stores your assets, including images, JavaScript, and CSS.
The Resources Directory
The resources directory houses your views along with your uncompiled assets, such as CSS or JavaScript.
The Routes Directory
The routes directory encompasses all route definitions for your application. Dreamfork comes with default route files: web.php and api.php.
The web.php file includes routes that the RouteServiceProvider assigns to the web middleware group. If your application doesn't provide a stateless, RESTful API, most of your routes will likely be defined in the web.php file.
The api.php file includes routes that the RouteServiceProvider assigns to the api middleware group. These routes are designed to be stateless. Requests entering the application through these routes are meant to be authenticated via tokens and won't have access to session state.
The Storage Directory
The storage directory houses your logs, compiled Vision templates, and other files generated by the framework. It is organized into app, framework and logs directories. The app directory is suitable for storing any files generated by your application. The framework directory is designated for framework-generated files and caches. Lastly, the logs directory contains your application's log files.
For user-generated files, like images, styles, and scripts that need to be publicly accessible, you can utilize the storage/app/public directory. To make these files accessible to the public, create a symbolic link at public/storage pointing to this directory. You can achieve this by executing the php dfork storage:link command or php dfork storage:unlink to unlink symbolic link.
It is possible to create symbolic link to
storage/app/publicwith a custom defined name, allowing files to be accessed under the specified name. This can be achieved using thephp dfork storage:link custom_namecommand.
The Vendor Directory
The vendor directory contains your Composer dependencies.
The App Directory
The Controllers Directory
The controllers directory stores controllers that utilize models. Almost all of the logic responsible for handling requests entering your application will be found in this directory.
The Exceptions Directory
The exceptions directory houses your application's exception handler and serves as a suitable location for any exceptions thrown by your application. If you wish to customize the way your exceptions are logged or rendered, you should make adjustments to the Handler class within this directory.
The Models Directory
The models encompasses all of your ORM model classes. The ORM included with Dreamfork offers a straightforward implementation for interacting with your database. Each database table has a corresponding "Model" that facilitates interaction with that table. Models enable you to query data from your tables and insert new records into the table.
The Providers Directory
The providers houses all the service providers for your application. Service providers assist in bootstrapping your application. Currently, it is not supported to easily create your own providers.