GithubHelp home page GithubHelp logo

devops's Introduction

PHP initial Project

Main structure of php project. Folders / files:

  • app
    • controllers
    • models
    • views
  • config
  • lib
    • base
  • web

Usage

The web/index.php is the heart of the system. This means that your web applications root folder is the “web” folder.

All requests go through this file and it decides how the routing of the app should be. You can add additional hooks in this file to add certain routes.

Project Structure

The root of the project holds a few directories: /app This is the folder where your magic will happen. Use the views, controllers and models folder for your app code. /config this folder holds a few configuration files. Currently only the connection to the database. /lib This is where you should put external libraries and other external files. /lib/base The library files. Don’t change these :) /web This folder holds files that are to be “downloaded” from your app. Stylesheets, javascripts and images used. (and more of course)

The system uses a basic MVC structure, with your web app’s files located in the “app” folder.

app/controllers

Your application’s controllers should be defined here.

All controller names should end with “Controller”. E.g. TestController. All controllers should inherit the library’s “Controller” class. However, you should generally just make an ApplicationController, which extends the Controller. Then you can defined beforeFilters etc in that, which will get run at every request.

app/models

Models handles database interaction etc.

All models should inherit from the Model class, which provides basic functionality. The Model class handles basic functionality such as:

Setting up a database connection (using PDO) fetchOne(ID) save(array) → both update/create delete(ID) app/views Your view files. The structure is made so that having a controller named TestController, it looks in the app/views/test/ folder for it’s view files.

All view files end with .phtml Having an action in the TestController called index, the view file app/views/test/index.phtml will be rendered as default.

config/routes.php

Your routes around the system needs to be defined here. A route consists of the URL you want to call + the controller#action you want it to hit.

An example is: $routes = array( ‘/test’ => ‘test#index’ // this will hit the TestController’s indexAction method. );

Error handling

A general error handling has been added.

If a route doesn’t exist, then the error controller is hit. If some other exception was thrown, the error controller is hit. As default, the error controller just shows the exception occured, so remember to style the error controller’s view file (app/views/error/error.phtml)

Utilities

devops's People

Contributors

franenlanube avatar juanandprog avatar

Stargazers

 avatar  avatar

Watchers

Rubén avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.