Skip to content

rubenperezlopez/almacil-php-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub last commit GitHub tag (latest by date) Packagist PHP Version Support GitHub

♥️ Almacil PHP Core

This is a simple MVC framework written in PHP for rapid development of small projects.


Do you want to contribute?
Donate 1€

Features

  • Routes
  • Internationalization
  • Database
  • Cache
  • HTTP Requests
  • Minimum dependencies

Installation

Installation is possible using Composer

composer require almacil/php-core

Usage

Create an instance of \Almacil\App:

// Require composer autoloader
require __DIR__ . '/vendor/autoload.php';

$rootDir = __DIR__;
$configFile = 'app.config.json';

// Create de instance
$app = new \Almacil\App($rootDir, $configFile);

app.config.json example

{
  "display_errors": true,
  "languages": [
    "es_ES",
    "en_GB"
  ],
  "timezone": "Europe/Madrid",

  "spa": {
    "enabled": true
  },
  "cache": {
    "enabled": true,
    "directory": "disk/cache",
    "time": 10
  },
  "database": {
    "enabled": true,
    "directory": "disk/database/",
    "extension": "json"
  },
  "http": { // Developing
    "enabled": true,
    "defaultPrefix": ""
  },
  "translate": {
    "enabled": true,
    "directory": "disk/i18n/",
    "findMissingTranslations": false
  },
  "router": {
    "enabled": true,
    "routesFile": "app.routes.json"
  },

  "environments": {
    "baseFile": "environments/base.json",
    "production": {
      "domain": "id.core.almacil.com",
      "propertiesFile": "environments/production.json"
    },
    "development": {
      "domain": "localhost:8000",
      "propertiesFile": "environments/development.json"
    }
  }
}

display_errors: true | false
Con el valor en true se mostrarán los errores de PHP, útil para depuración. En producción se recomienda ponerlo en false.

languages: array
Definimos un array con los idiomas válidos para nuestra aplicación web. Almacil Core recupera el idioma del navegador del usuario y, si es necesario, lo redirecciona para poner la abreviación del idioma en el primer segmento de la url.

timezone: string
Define el timezone de PHP.

spa: object
    enabled: true | false
    Esta funcionalidad permite navegar a través de la aplicación web sin refrescar la página.
    Más información aquí.

cache: object
    enabled: true | false
    directory: string
    time: number

SPA (Single Page Application)

Podemos hacer lo siguiente con Javascript para cambiar de página:

const route = '/contact';
captain.navigate(route);

app.routes.json example

{
  "middlewares": [
    "middlewares/variables"
  ],
  "default": {
    "responseType": "html",
    "head": "layout/head",
    "beforeContent": "layout/before-content",
    "afterContent": "layout/after-content",
  },
  "routes": [
    {
      "path": "/contact",
      "component": "pages/contact"
    },
    {
      "path": "/articles",
      "component": "pages/articles",
      "cache": {
        "enabled": false
      },
      "data": {}
    },
    {
      "path": "/articles/{article_id}",
      "component": "pages/article",
      "data": {
          "pageType": "article"
      }
    },
    {
      "path": "/",
      "component": "pages/home",
      "cache": {
        "enabled": true,
        "time": 60, // seconds
      }
    }
  ],
  "notFound": {
    "component": "pages/404"
  }
}


Writting in my spare time...



Do you want to contribute?
Donate 1€


Made with ❤️ by developer for developers

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages