Coder Social home page Coder Social logo

dframe / dframe Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 5.0 2.71 MB

PHP framework to build web applications, APIs and microservices.

Home Page: https://dframeframework.com/

License: MIT License

PHP 97.97% Shell 2.03%
dframe dframeframework framework php php-framework phpframework smarty

dframe's Introduction

Dframe - PHP Framework

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

php framework dframe logo

The basic framework to help you build MVC project.

What's included?

Requirements

  • PHP >= 8.1
  • Rewrite Module (Nginx/Apache )
  • Composer

Installation

Framework Core

$ composer require dframe/dframe

Demo skeleton project

$ composer create-project dframe/dframe-demo project_name

License

Open-sourced software licensed under the MIT license

dframe's People

Contributors

amadeuszxd avatar dusta avatar pajsmolinski avatar pawelkg avatar peter279k avatar szmagli avatar troold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dframe's Issues

Switching between friendly links

Describe the bug
After Switch friendly links can not find route

To Reproduce
Steps to reproduce the behavior:

  1. Work localhost/page/index
  2. Stop working localhost/index.php?task=page&action=index

View change variables are ignored

View change variables are ignored by reloading

    public function renderInclude($name, $path = null)
    {

        $smartyConfig = Config::load('view/smarty');

Undefined varible $str

src\Asset\Assetic.php
In place where is

fwrite($out, $str);

There is no defined $str should be $msg

Session class constructor should pass the $options

Consider the code snippets in Session class.

class Session
{

    function __construct()
    {
        $name = '_sessionName';
        $options = [];

        $this->name = $name;

        if (!isset($_SESSION)) {
            $cookie = array(
                'lifetime' => isset($options['cookie']['lifetime']) ? $options['cookie']['lifetime'] : 0,
                'path' => isset($options['cookie']['path']) ? $options['cookie']['path'] : '/',
                'domain' => isset($options['cookie']['domain']) ? $options['cookie']['domain'] : null,
                'secure' => isset($options['cookie']['secure']) ? $options['cookie']['secure'] : isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : null,
                'httponly' => isset($options['cookie']['httponly']) ? $options['cookie']['httponly'] : false,
            );
.......

It seems that the $options variable will always be empty array and the ?: operator will be useless.
I think it should be the argument for this constructor.

Demo isn't working

Hi,
I used this command

$ composer create-project dframe/dframe-demo yourAppName
and demo isn't work for me.

The error:
`
Notice: Use of undefined constant APP_DIR - assumed 'APP_DIR' in D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\vendor\dframe\dframe\src\Config.php on line 22

Fatal error: Uncaught Dframe\BaseException: Not Found Config APP_DIRConfig/router.php in D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\vendor\dframe\dframe\src\Config.php:26 Stack trace: #0 D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\vendor\dframe\dframe\src\Config.php(35): Dframe\Config->__construct('router', NULL) #1 D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\vendor\dframe\dframe\src\Router.php(43): Dframe\Config::load('router') #2 D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\vendor\dframe\dframe\src\Core.php(17): Dframe\Router->__construct() #3 D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\web\index.php(13): Dframe\Core->run() #4 {main} thrown in D:\Programy\Xampp\7_1_9\htdocs\afterrent-api\vendor\dframe\dframe\src\Config.php on line 26`

Incorrect matching of routeCollection

Describe the bug

Issue with matching routeCollection

To Reproduce

We have this routeCollection:

 'routes' => array(
        'documents/:pageId/title' => array(
            'page/[pageId]/title',
            'task=page&action=show&pageId=[pageId]'
        ),

        'documents/:pageId/article/title' => array(
            'page/[pageId]/article/title',
            'task=page&action=show&pageId=[pageId]'
        )
 )

When attemting to enter this route

/page/66/article/title

Regexp parses it as:

[pageId] == 66/article

and detects that we want to enter this route:

        'documents/:pageId/title' => array(
            'page/[pageId]/title',
            'task=page&action=show&pageId=[pageId]'
        )

Expected behavior

Should find this route

        'documents/:pageId/article/title' => array(
            'page/[pageId]/article/title',
            'task=page&action=show&pageId=[pageId]'

Additional info

Currently you can work this around with backslash:

 'routes' => array(
        'documents/:pageId/title' => array(
            'page/[pageId]\/title',
            'task=page&action=show&pageId=[pageId]'
        ),

        'documents/:pageId/article/title' => array(
            'page/[pageId]\/article/title',
            'task=page&action=show&pageId=[pageId]'
        )
 )

Initialize CONTRIBUTING guide

As title, it should add the CONTRIBUTING guide and let others can contribute this correctly.
Here is the Requirements section I suggest:

Requirements

If the project maintainer has any additional requirements, you will find them listed here.

  • PSR-2 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.

  • Add tests! - Your patch won't be accepted if it doesn't have tests.

  • Document any change in behaviour - Make sure the README.md and any other relevant documentation are kept up-to-date.

  • Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.

  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.

  • Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

Happy coding!

Here is the requirements section reference.

Import PSR-2 coding style tool

As title, the PSR-2 coding style I think it's important for every repositories in this org.
And I think we can add the PSR-2 coding style tool to detect the coding style and make these codes consistent. Consider the two coding style tools:

  • StyleCI: It's a service that can check coding style automatically when pushing the latest commit.
  • PHP_CodeSniffer

It can also add this required item in CONTRIBUTING.md ๐Ÿ‘ .

Enhance Token module

When I look at the Token class, this is a very simple to implement the token package.
How about considering the csrf-tokenservice
I think we can try to inherit and integrate this with the original Token class methods.

Replace the array() with []

As title, it's time to use the [] to define the array.
And this feature is supported since php-5.4.
It' also related to this PR.

Uncaught TypeError: Argument

When generating assesses throw

[11-Aug-2018 10:31:56 UTC] PHP Fatal error: Uncaught TypeError: Argument 3 passed to Dframe\Asset\Exceptions\AsseticException::__construct() must be an instance of Exception or null, 4. See error

PSR-16

Implement SimpleCache PSR-16 for Token class and Messages Class

Replace isset function with ?? in Session class

Consider the $cookie array in Session class constructor:

 $cookie = array(
                'lifetime' => isset($options['cookie']['lifetime']) ? $options['cookie']['lifetime'] : 0,
                'path' => isset($options['cookie']['path']) ? $options['cookie']['path'] : '/',
                'domain' => isset($options['cookie']['domain']) ? $options['cookie']['domain'] : null,
                'secure' => isset($options['cookie']['secure']) ? $options['cookie']['secure'] : isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : null,
                'httponly' => isset($options['cookie']['httponly']) ? $options['cookie']['httponly'] : false,
            );

Since php-7.0, it can use the ?? to let this code be readability ๐Ÿ‘ .

 $cookie = array(
                'lifetime' => $options['cookie']['lifetime'] ?? 0,
                'path' => $options['cookie']['path'] ?? '/',
                'domain' => $options['cookie']['domain']?? null,
                'secure' => $options['cookie']['secure'] ?? ($_SERVER['HTTPS'] ?? null),
                'httponly' => $options['cookie']['httponly'] ?? false,
            );

Replaces array() with [].

Use [] instead of array(). It is shorthand, looks better, and is the standard way of instantiating new arrays.

static session name

In session.php is static $name

        $name = '_sessionName';

Should be

        $name = SESSION_NAME ?? '_sessionName';

Add more tests

Add test for

-Loader
-View
-Assets
-Messages
-Session

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.