Giter Site home page Giter Site logo

php-oo-autoload's Introduction

php-oo-autoload

PHP en OO avec un autoload manuel et installation de Twig via composer

Database

Importez en MariaDB en désactivant les clefs étrangères (port 3308)

    datas/import.sql

strucure de la DB

Création d'un autoload

Pour charger automatiquement des classes depuis le dossier model

spl_autoload_register(function ($class_name) 
{
    include "../model/"$class_name . '.php';
}
);

Création d'un slug multi-langues

Pour avoir un Slug toujours valide

public static function slugify($text)
{
   // replace non letter or digits by -
   $text = preg_replace('~[^\pL\d]+~u', '-', $text);

   // transliterate
   $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

   // remove unwanted characters
   $text = preg_replace('~[^-\w]+~', '', $text);

   // trim
   $text = trim($text, '-');

   // remove duplicate -
   $text = preg_replace('~-+~', '-', $text);

   // lowercase
   $text = strtolower($text);

   if (empty($text)) {
   return 'n-a';
   }

   return $text;
}

Composer

Installez composer à cette URL:

https://getcomposer.org/

Twig

Pour installer Twig:

composer require "twig/twig:^3.0"

Pour la documentation:

https://twig.symfony.com/doc/3.x/

Vendor

On met le dossier vendor dans le .gitignore, en effet, pour réinstaller les dépendances il suffira, après avoir chargé le projet, de les installer grâce au composer.json avec la commande :

composer install

php-oo-autoload's People

Contributors

mikhawa avatar audreyantony avatar

Watchers

James Cloos 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.