Following document explains minimum steps required to setup a working Fano web application on development machine.
- Linux or FreeBSD
- Free Pascal >= 3.0
- Apache 2.4
- mod_cgi or mod_cgid
- Fano CLI
- Working Internet connection.
- Root privilege (for setting up virtual host).
Install Fano CLI
Make sure all requirements above are met. Run
$ fanocli --project-cgi=Hello $ cd Hello $ fanocli --controller=Home --route=/ $ ./build.sh $ sudo fanocli --deploy-cgi=hello.fano
Run it from browser
Open web browser and go to
http://hello.fano. You should see
Home controller text is printed in browser. Congratulations, your application is working.
Let us take a look at each command above to understand what it does.
Following command tells Fano CLI to create CGI web application project in
Hello directory. Directory must not exist. Read Creating Project with Fano CLI for creating different web application project (FastCGI, SCGI, uwsgi or http).
$ fanocli --project-cgi=Hello
We change active directory to newly created
$ cd Hello
Create controller name
HomeController.pas that will handle request to route
/. For more information regarding route, read Working with Router.
$ fanocli --controller=Home --route=/
--route=/, by default, Fano CLI will create route same as lower case of controller’s name, i.e,
/home. If you omit
--route=/ then you can only access
HomeController using URL
http://hello.fano/home instead of
Setup a virtual host for domain
hello.fano and associate it with our CGI application binary.
$ sudo fanocli --deploy-cgi=hello.fano
--deploy-cgi modifies web server configuration and reload it. That is why you need to use
sudo command. Read Deployment for deploying different protocol web application project (FastCGI, SCGI, uwsgi, http).
Project directory walkthrough
Fano Framework has no opinion about your project directory structure. You can structure your project directories and files the way you like. However, Fano CLI creates several files and directories that follows certain assumptions.
src, application project source code directory
bin, compiled binaries output directory,
config, application configuration directory
resources, application resources directory, such as HTML templates, SCSS, etc.
storages, application runtime-generated files directory, such as session files, logs etc.
tools, helper shell scripts directory, such as scripts to clean compiled binaries.
- Main program source code is
- Main unit
src/bootstrap.pasglues all modules.
- Home controller
src/App/Home/Controllersis code that prints
- Include file
src/Routes/Home/route.incassociates default URL
/with home controller.
- Include file
src/Dependenciesdirectory, registers factory class for home controller.
- Step by Step Tutorials
- Scaffolding with Fano CLI
- Creating Hello World application with Fano CLI