Skip to content
MrFibunacci edited this page Oct 13, 2017 · 12 revisions

1 Getting started

Start here to learn the essentials about developing web applications with Framy.

1.1 Setup

1.2 Directory Structure

1.2.1 Introduction

The default Framy application structure is intended to provide a great starting point for both large and small applications. Of course, you are free to organize your application however you like. Framy imposes almost no restrictions on where any given class is located.

1.2.2 The Root Directory

In the root directory is every file of the project and Framy.

1.2.2.1 The app Directory

Inside the app directory, as you might expect, are all the core Class of your code and Framys. However especially for you its required to know that specially folder custom is for you. Because you are Special. Happy Birthday.

1.2.2.2 The config Directory

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

1.2.2.3 The public Directory

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

1.2.2.4 The routes Directory

The routes directory contains the files web.php and api.php. Where you register the web an api routs.

1.2.2.5 The storage Directory

The storage 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 and everything else you want to store.

1.2.3 The App Directory

The app Directory which contains the core code of Framy. In the following topics I will shortly explain what the components, in the Component folder, are meant to do. The folder is called like that because the folder needs to mach with the namespaces and component sound better in an namespace.

1.2.3.1 ClassLoader

Is the house made auto loader currently only supporting PSR-0 standard.

1.2.3.2 Config

Made to simplify interaction with config files.

1.2.3.3 Database

Communication with every type of Database under usage of Medoo.

1.2.3.4 Route

Routing as we know. you can use a self made routing tool or you can use Klein.

1.2.3.5 StdLib

Standard Library with some basic function like an simple validation trait or different Objects like ArrayObject for an better work with array in this example. And exception classes.

1.2.3.6 Stopwatch

Specially to profile your code. As the name says its basically an Stopwatch for your code witch manny extra features.

1.2.3.7 Storage

To work with files and directory's.

1.2.3.8 TemplateEngine

Templates with different bridges like Smarty or mustache

1.2.3.9 Validation

Validate data.

1.3 Creating Pages

Quite at first you should register the route. You can read how to exactly do this under Routing. But here an example:

$klein->respond("GET", "/", function(){
    view("welcome");
});

Inside the function can everything happen like calling an method from an class. In this example we will not do this.

We will just use the view() helper function and display the "welcome" template

To do this we need to add an Template. Lets name it welcome.tpl (.tpl ending -> syntax Smarty requires)

We add the file under storage/templates.

welcome.tpl shall look like this:

<head>
    <title>Framy</title>
</head>
<body>
<div class="flex-center position-ref full-height">
    <div class="content">
        <div class="title m-b-md">
            Framy
        </div>
    </div>
</div>
</body>
</html>

1.4 Routing

Klein Documentation.