GithubHelp home page GithubHelp logo

youmy001 / apine-framework Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 13.31 MB

Modular MVC Framework ready for use as a RESTful API

License: MIT License

PHP 100.00%
framework php mvc mvc-framework mysql

apine-framework's Introduction

APIne Framework

This repository is no longer maintained here. The project is now hosted as apinephp/legacy-framework on GitLab.

APIne is a simple to use modular MVC Framework ready for use as a RESTful API. It intends to be a general purpose framework and a RESTful service providing basic session management, authentication, routing, and database abstraction without including useless tools. APIne's focus is to let you work without imposing to relearn PHP.

You may per se, use APIne for solely for its routing system and its MVC approach then use your favorite PHP libraries for everything else.

APIne already implements a comprehensive session manager, a basic yet effective Entity manager, and, TWIG as its template manager โ€” enough to boot any kind of project.

Requirements

For APIne 2:

  • PHP 7.2 or greater with the PDO extension
  • MySQL 5.6 or MariaDB 10.1 or greater
  • Apache 2.4 with mod_rewrite

For APIne 1.1:

  • PHP 5.6 or greater with PDO extension
  • MySQL 5.6 or MariaDB 10.1 or greater
  • Apache 2.4 with mod_rewrite

The project using APIne must be installed at the root of a host that must include the instruction AllowOverride FileInfo Options Indexes for the default settings. PHP's user must also have writing permissions on the project directory.

APIne does not officially support any other HTTP server (nginx, lighttpd, ...). If you are using one of those you might need modify your server's configuration.

Installation

APIne Framework is available as a Composer Package on Packagist as well as a standalone project.

APIne 2.0 is currently under heavy development thus is not ready for use. It is recommended to install the stable version of the framework instead.

With Composer

Add the following line to your composer.json file : "youmy001/apine-framework": ^1.1". Or enter this command : $ composer require youmy001/apine-framework.

Standalone

Clone this repository in your working directory : $ git clone https://github.com/Youmy001/apine_framework.git. Then checkout to the branch of the latest stable release: git checkout 1.1.x.

Quick Start a Project

To quickly start a new project execute the assistant in a web browser located at http://[domain_name_of_your_project]/apine-framework/install.php if APIne is used standalone or http://[domain_name_of_your_project]/vendor/youmy001/apine-framework/install.php if it is used as a composer package, and follow the steps. The assistant will automatically generate a basic config, an empty locale, a .htaccess file, and a basic index.php and will automatically download the latest version of Composer's binary if you are using the standalone version.

The assistant will also try to import some tables essential for APIne's operation. Make sure you already created a database before launching the assistant and that the database is accessible from your project's perspective.

If you run a standalone version of APIne's, install depedancies using this command after going through the assistant : $ php composer.phar install.

Manually Start a Project

First of all, in order to use APIne Framework, you must copy this file to the root of your project :

  • apine-framework/Installation/htacess_template.php

Then replace the PHP tag by the path to APIne. If you are using APIne as a Composer package, this will be /vendor/youmy001/apine-framework. If you are using a standalone APIne, this will likely be /apine-framework. And rename the file .htaccess.

Next, create a index.php file and add the following content in it:

require_once 'vendor/autoload.php'; // If APIne is a Composer package
//require_once 'apine-framework/Autoloader.php'; // If APIne is standalone

$loader = new Apine\Autoloader();
$loader->register();

$apine = new Apine\Application\Application();
$apine->set_mode(APINE_MODE_DEVELOPMENT);
$apine->run(APINE_RUNTIME_HYBRID);

Finally, you will need to create a file name config.ini that will contain various configuration information. Complete the following in your config file :

[application]
title = "Project Name"
author = "Author Name"
description = "Description"
[database]
host = "localhost"
type = "mysql"
dbname = "projectdb"
charset = "utf8"
username = "root"
password = ""
[localization]
timezone_default = "America/New_York"
locale_default = "en_US"
locale_detection = "yes"
locale_cookie = "no"
[runtime]
token_lifespan = "600"
default_layout = "default"

Learn More

Learn More at the following links :

Support

Get support at the following links :

License

The APIne Framework is distributed under the MIT license. See the LICENSE file for more information.

apine-framework's People

Contributors

youmy001 avatar binarmorker avatar

Stargazers

Alain Dessi avatar  avatar

Watchers

 avatar  avatar

Forkers

cgrafton

apine-framework's Issues

Multiple groups

The actual groups are very useful for permission management, but it would be better to integrate it as a list of groups, to use more complex permissions. The method "get_group" could be renamed as "get_groups" and return a "Liste" of groups, and "set_group" could become "add_group".

Liste::key_exists() throws a notice on elements with arrays in them

The method array_diff_assoc on line 352 in lib/core/Liste.php throws a notice when at least one of the two compared objects contain an array. That is because array_diff_assoc then treats the object as a multidimentional array, which it does not support. It then gives the following:

Notice: Array to string conversion in lib/core/Liste.php at line 352

A possible fix would be to serialize the objects before passing them into an array_diff, then unserializing the result, like this:

$diff = array_map('unserialize', array_diff(array_map('serialize', $pageids), array_map('serialize', $parentpage)));

ApineUser::has_group() always false

When I call ApineUser::has_group() it always returns false even if users have a group assigned by default during registration. Currently the only way to fix that is to call ApineUser::get_group() beforehand.

Setup wrong locales directory on installation

The installer add the reference to a directory "resources/language" for the locales which does not exists. It should instead add "resources/languages" as the default locales directory.

Add custom port support

Many modules in the framework currently implies the request come from the default http and https ports. When testing with custom ports the application will fail to generate valid links and return 404 response.

Plausible addition point would be inside Request and URLHelper classes.

Bad query

In the class ApineUserFactory, the method "create_by_group" contains a bad SQL query. Normally, "SELECT ID from apine_users where group=$group" would work. In this case, the keyword "group" in reserved in MySQL and is therefore not considered a column name, but that specific keyword and thus the query fails. The query should be replaced by "SELECT ID from apine_userswheregroup=$group".

User authentication

The user authentication could use some customization outside of the "ApineUser" class. For example, a website administrator may want to authenticate users using the email insteal of the username, or even use both.

ApineSession login method does not login with email

The latest changes to the authentication that allow old and new passwords does not take into account that we may log in with our email address. Line 233 currently reads

if ((ApineUserFactory::is_name_exist($user_name) || ApineUserFactory::is_email_exist($user_name)) && ApineUserFactory::create_by_name($user_name)->get_register_date() < "2015-09-04") {

and should probably read something in those lines:

if ((ApineUserFactory::is_name_exist($user_name) && ApineUserFactory::create_by_name($user_name)->get_register_date() < "2015-09-04") || (ApineUserFactory::is_email_exist($user_name) && ApineUserFactory::create_by_email_address($user_name)->get_register_date() < "2015-09-04")) {

Wrong Default User

The default user is defined to be of type 70 in the database, but this type does not exist in the code. The codified type for a default user is 65, and the type for an admin is 77. Because of that, a newly created user is assigned a type that does not correspond to anything, therefore can't be used.

Non-existant constant

In the class ApineUser, the method "get_register_date" refers to a non-existant constant, APP_DATE_FORMAT. Data format should be defined in the config.

ApineFileImage is broken

ApineFileImage does not follow the same structure as ApineFile, and the functions used in ApineFileImage do not work anymore with its parent. Therefore, the class should use a rewrite in my opinion.

File crashes PHP on non-existing file

The constructor of lib/file/File.php uses the method fread without being enclosed in a try/catch, which means whenever it tries to read a file that doesn't exist, it crashes the whole script.

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.