Directory Structure


The default Octopy application structure is intended to provide a great starting point for both large and small applications. But you are free to organize your application however you like. Octopy imposes 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 contains the core code of your application. We'll explore this directory in more detail soon; however, almost all of the classes in your application will be in this directory.

The Public Directory

The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.

The System Directory

The system directory, as the name implies, contains all of your application's system files.

The Storage Directory

The storage directory contains your compiled Octopy templates, file based sessions, file caches, and other files generated by the framework. This directory is segregated into app, framework, and logs directories. The app directory may be used to store any files generated by your application. The framework directory is used to store framework generated files and caches. Finally, the logs directory contains your application's log files.

The storage/app/public directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible. You should create a symbolic link at public/storage which points to this directory. You may create the link using the php octopy storage:link command.

The Vendor Directory

The vendor directory contains your Composer dependencies.

The App Directory

The majority of your application is housed in the app directory. By default, this directory is namespaced under App and is autoloaded using the PSR-4 autoloading standard.

The app directory contains a variety of additional directories such as Console, DB, HTTP, and Provider. Think of the Console and HTTP directories as providing an API into the core of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are two ways of issuing commands to your application. The Console directory contains all of your Octopy commands, while the HTTP directory contains your controllers, middleware, and requests.

Many of the classes in the app directory can be generated by Octopy via commands. To review the available commands, run the php octopy --help command in your terminal.

The Config Directory

The Config directory, as the name implies, contains all of your application's configuration files. It's a great idea to read through all of these files and familiarize yourself with all of the options available to you.

The Console Directory

The Console directory contains all of the custom Octopy commands for your application. These commands may be generated using the octopy make:command command. This directory also houses your console kernel, which is where your custom Octopy commands are registered and your scheduled tasks are defined.

The Database Directory

The DB directory contains your database migrations, model, and seeds. If you wish, you may also use this directory to hold an SQLite database.

The Exceptions Directory

The Exceptions directory contains your application's exception handler and is also a good place to place any exceptions thrown by your application. If you would like to customize how your exceptions are logged or rendered, you should modify the Handler class in this directory.

The HTTP Directory

The HTTP directory contains your controllers, middleware, and form requests. Almost all of the logic to handle requests entering your application will be placed in this directory.

The Providers Directory

The Provider directory contains all of the service providers for your application. Service providers bootstrap your application by binding services in the service container, registering events, or performing any other tasks to prepare your application for incoming requests.

In a fresh Octopy application, this directory will already contain several providers. You are free to add your own providers to this directory as needed.

The Route Directory

The Route directory contains all of the route definitions for your application. By default, several route files are included with Octopy: Web.php, Api.php and Console.php.

The Web.php file contains routes that the RouteServiceProvider places in the web middleware group, which provides session state, CSRF protection, and cookie encryption. If your application does not offer a stateless, RESTful API, all of your routes will most likely be defined in the Web.php file.

The Api.php file contains routes that the RouteServiceProvider places in the api middleware group, which provides rate limiting. These routes are intended to be stateless, so requests entering the application through these routes are intended to be authenticated via tokens and will not have access to session state.

The Console.php file is where you may define all of your Closure based console commands. Each Closure is bound to a command instance allowing a simple approach to interacting with each command's IO methods. Even though this file does not define HTTP routes, it defines console based entry points (routes) into your application.

The View Directory

The View directory contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.