This is the front end code for sunnah.com. It is built atop the Yii 2 MVC framework.
The top level structure is divided into application code (in the application
folder) that includes MVC code and the public
folder which contains index.php
, css
, js
, and others.
Your webserver should point to the public folder. The Yii framework code needs to reside on the machine as well; its location is hardcoded into public/index.php
.
Under the application
folder, here are the important locations:
config/main.php
: All the configuration options, including URL routes, database connections, etc.modules/front/controllers
: All controller classes. There are three main controllers: the search page, the index and sitewide pages, and the collection controller which includes actions for displaying collections, books, and ahadith.modules/front/models
: All model classes. Each kind of object has a model class. E.g. hadith, book, collection.modules/front/views
: Each controller has actions which have view code. This folder contains the view code.modules/front/views/layouts
: Other view code corresponding to side menus, search box, widgets, etc.views/layouts
: Sitewide view code like column layout, footer.public
folderindex.php
file as default document.php
files in iisinstall
comand of composer in the root dirIf you don't want to set up a complete dev environment on your host, you can use a Docker container to host the PHP environment, dependencies, and web server. The source code is mounted as a volume inside the container, so any changes will reflect immediately inside the container without having to rebuild it.
Launching the dev container is composed of a simple docker-compose
command. First however, copy the .env.local.sample
file to .env.local
(important). Then run the following command in the same directory as the Dockerfile:
docker-compose up --build
You should then be able to access the webserver using port 80 on the container's host.
Use Visual Studio Code with Remote Containers extensions to attach to running instance and try out changes rapidly.
Use the php cs fixer extension for formatting code.