PHPackages                             karma-solutions/karmafw - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. karma-solutions/karmafw

ActiveLibrary[Framework](/categories/framework)

karma-solutions/karmafw
=======================

PHP framework

085PHP

Since Jun 27Pushed 3y agoCompare

[ Source](https://github.com/karma-solutions/karmafw)[ Packagist](https://packagist.org/packages/karma-solutions/karmafw)[ RSS](/packages/karma-solutions-karmafw/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

```
  _  __                          _______        __
 | |/ /__ _ _ __ _ __ ___   __ _|  ___\ \      / /
 | ' // _` | '__| '_ ` _ \ / _` | |_   \ \ /\ / /
 | . \ (_| | |  | | | | | | (_| |  _|   \ V  V /
 |_|\_\__,_|_|  |_| |_| |_|\__,_|_|      \_/\_/

```

Présentation
============

[](#présentation)

KarmaFW est un mini framework PHP qui gère le routing, les templates et les connexions aux bases SQL.

Fonctionnalités
---------------

[](#fonctionnalités)

- Routing Web
- Templates PHP/HTML
- Connexions SQL
- FileUpload web
- Envoi d'emails (SMTP)
- Paiements: Paypal, Payplug, Stripe
- Auth: GoogleAuthenticator, SmsAuthenticator
- PDF: création de PDF (HTML to PDF)
- SMS: Envoi de SMS (Free &amp; SmsEnvoi.com)
- Hooks PHP
- Bitly: génération d'url bit.ly

### Pré-requis

[](#pré-requis)

Composer est nécessaire afin de gérer les autoload des classes PHP.

Structure d'une [app console](src/ConsoleApp.md)
------------------------------------------------

[](#structure-dune-app-console)

```
bin
    app_console.php
config
    config.php
src
    scripts
        my_test_script.php
    Models
    helpers
vendor
    karmasolutions/karmafw

```

Structure d'une [app web](src/)
-------------------------------

[](#structure-dune-app-web)

```
config
    config.php
    routes.php
public
    .htaccess
    index.php
    images
    css
    js
    vendor
src
  Controllers
    MyAppController
    HomeController
  Models
    User
  helpers
    helpers_myapp.php
templates
    homepage.tpl.php
vendor
    karmasolutions/karmafw

```

Configuration
=============

[](#configuration)

Les paramètres de configuration de l'application se déclarent dans le fichier ./config/config.php

Le nom de l'application est à définir dans la variable APP\_NAME.

```
define('APP_NAME', "Mon app PHP");

```

### [Routing](src/Routing/)

[](#routing)

Les routes se déclarent dans le fichier ./config/routes.php

Chaque route est attribuée à la méthode d'un controller à renseigner.

### [Templates](src/Templates/)

[](#templates)

Le chemin d'accès aux fichiers de templates se fait dans la variable de config TPL\_DIR.

```
define('TPL_DIR', APP_DIR . '/templates');

```

### [Database SQL](src/Database/Sql/)

[](#database-sql)

Les informations de connexions à MySQL se font dans la variable de config DB\_DSN.

```
define('DB_DSN', 'mysql://user:password@localhost/db_name');

```

Utilisation
===========

[](#utilisation)

Création d'un nouveau projet
----------------------------

[](#création-dun-nouveau-projet)

```
$ mkdir /var/www/my_app
$ cd /var/www/my_app

```

1. Composer

```
$ composer init

```

Ajouter ceci dans composer.json :

```
{
    "repositories": [
        {
            "type": "path",
            "url": "/put/here/the/path/to/karmafw"
        }
    ],
    "require": {
        "karmasolutions/karmafw": "dev-master",
        "filp/whoops": "^2.2@dev"
    }
}

```

3. DocumentIndex

```
mkdir -p public
nano public/index.php

```

```
