2017 © Pedro Peláez
 

library sophwork

Simple PHP Oject Framework

image

sophwork/sophwork

Simple PHP Oject Framework

  • Wednesday, November 25, 2015
  • by syu93
  • Repository
  • 3 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Sophwork

Simple PHP Oject Framework

This micro-framework was first created to help people learning Object Oriented Programming through a framework., (*1)

It's quite simple to get started and quite alike with a well known micro-framework : Silex (based on Symfony components)., (*2)

The aim is not to provide a production ready framework that you should use in your enterprise project but mostly to try things and to bootstrap a small structured project very quickly., (*3)

Installation

The recommended way to install Sophwork is through Composer:, (*4)

$ composer require sophwork/sophwork "0.1.1", (*5)

As you can also download it from : here, (*6)

Getting started

Server configuration

You first need to configure your server to use Sophwork. You can take exemple on the .htaccess file in the sources folder. (Make sure Apache2 mod_rewrite is enabled: here is a quick tutorial)., (*7)

#Default htaccess
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Using Sophwork

<?php

use Sophwork\app\app\SophworkApp;
use Sophwork\modules\handlers\requests\Requests;

// If you're not using composer, you must define your sources path
$autoloader->sources = __DIR__ . '/../src/';

/*
 *  Create a new applicaion with the Sophwork class
 *  It will create 3 new class :
 *      - appController class
 *      - appModel class
 *      - appView class
 *
 *  Set up app parameters here or in the config file
 */
$app = new SophworkApp();

Then you need to define your routes, (*8)

<?php

/**
 * Simply declare your routes and the pattern to match
 * and link them to the controller
 *
 * You can match the following http requests
 *      - get
 *      - post
 *  You can also attribute them a name so you can use UrlGenerator to create links
 */
$app->get('/', function(SophworkApp $app, Requests $request) {
    return "

Hello World !

"; });

As you can see you can declare controller directly through your router, but I mostly recommend to do it in a proper controller file :, (*9)

<?php
// src/MyApp/Controller/Home.php

namespace MyApp\Controller;

use Sophwork\app\app\SophworkApp;
use Sophwork\modules\handlers\requests\Requests;

class Home
{
    public function show(SophworkApp $app, Requests $requests) {
        return 'Hello World';
    }
}

And then call the right method in the controller you've just define :, (*10)

<?php
// index.php
//...
// Separate controller file (recommended)
$app->get('/', ['MyApp\Controller\Home' => 'show'], 'home');

Now you have configured your app, it's about time to actually run it (It will not run any of your controllers, unless you call this method), (*11)

// Run the actual app
$app->run();

Tests

Sophwork isn't tested yet. (As I said it's not production ready yet)., (*12)

License

Sophwork is licensed under the MIT license., (*13)

The Versions

25/11 2015

dev-dev-application

dev-dev-application

Simple PHP Oject Framework

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar syu93

22/11 2015

dev-master

9999999-dev

Simple PHP Oject Framework

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar syu93

16/11 2015

0.1.1

0.1.1.0

Simple PHP Oject Framework

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar syu93

08/11 2015

0.1.0

0.1.0.0

Simple PHP Oject Framework

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

  • php >=5.3.9

by Avatar syu93