Coder Social home page Coder Social logo

framework's Introduction

Slayer - Structured Phalcon Framework

#####Phalcon Rank Phalconist

#####Code Standard SensioLabsInsight

#####Master Status: Build Status

Slayer is made to support dependencies while still reaching the speed of Phalcon Framework, it is built with extensive packages such as flysystem, symfony components, swiftmailer, phinx and many more (refer to composer.json)

Contributing

Please read the CONTRIBUTING.md

You can pull the most updated branch dev, create a pull request of your forked branch updates, issues should be reported using GitHub's Issues and all security concerns should be emailed to [email protected] promptly.

Thanks to all contributors.

License

Slayer is an open-source and licensed under MIT License.

framework's People

Contributors

daison12006013 avatar sergeyklay avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

framework's Issues

Upgrade to Class Preloader 3.x

Hi, I am the current lead on Class Preloader, and I noticed you're currently using an older version. I'd recommend upgrading to 3.x. Let me know if you need any help with the upgrade. ;)

Enhancement on Dispatcher

Right now, we are relying on the default way to run the phalcon application. What I am planning is to execute our own dispatcher and re-call all existing events it has.

But we also need to consider about Route Middleware and Controller Middleware.

PHP 7 Error

ErrorException in FlattenException.php line 76: Uncaught TypeError: Argument 1 passed to Symfony\Component\Debug\Exception\FlattenException::create() must be an instance of Exception, instance of Error given

This happens because of the changes on error handling that happened on php 7

make all tests pass

In master branch, we should have only passing build, need to make all the tests pass :)

Model create does not return id

Hi everyone, I have started used this framework for few weeks and I got an issue that when I use Model::create(), it doesn't auto assign id to my model
For example:

$user = new User();
$user->name = "My name";
$user->create();

echo $user->id; // Result always is "0"

I tried it with raw Phalcon, and got correct id (auto increment) after create

I searched it on google and found this solution, set persistent => true in config/database.php

'mysql' => [
            'host'     => env('DB_HOST', 'localhost'),
            'port'     => env('DB_PORT', 3306),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'dbname'   => env('DB_DATABASE', 'slayer'),
            'persistent' => true,
            'charset'  => env('DB_CHARSET', 'utf8'),
            'class'    => Phalcon\Db\Adapter\Pdo\Mysql::class,
        ],

But I think this solution is not the correct approach. Could you please help to show me what I should do?

Controller logic is broken

Clarity\Support\Phalcon\Mvc\Controller
has broken logic for initialization
beforeExecuteRoute method try to call initialize()
but framework should calls this method only once, in your case it could be twice and more.
**The initialize() method is only called if the ‘beforeExecuteRoute’ event is executed with success. This avoid that application logic in the initializer cannot be executed without authorization.

make use of any return type possible from controller

As of now controllers can return string, view or a response (we can't even return a model, which is shame). Since PHP doesn't support generic type, we don't know return type of controller just by looking at the doc block.

My proposal: if a controller returns something other than view or a string, we wrap it ourselves in a response and return that. Which will allow me to do something like this:

class IUser {
    public $name;
    public $email;
    public $id
}
class Users extends Controller {
    /**
    * @return IUser
    */
    public function getById() {
        $user = new IUser();
        $user->email = "[email protected]";
        $user->name = "Something";
        $user->id = 3;
        return $user;
    }
}

In this case, we have a lot of information right there. Or anything actually, a model, a collection, anything should do.

In order to do this, we'll need to overwrite the handle method of application and should tackle the response type. I do think this handle method is way too long and it should really separate the handling of response separately in a method instead of writing a thousand lines of code (easy to test if we separated two different things to two different methods). Benefit of separating would include user being able to overwrite smaller pieces of component rather than having to overwrite the whole big method.

Automatic SDK generation for APIs

Since it's already generating routes with controllers and action, I think it'd be great if we could automatically generate SDK as well.

The way I'd propose is the following:
We know what the client is sending, and what the client will get through the docblocks, we could put in a limitation where people have to create some sort of interface or "model" (not relating to eloquent), which client either passes or gets.

Let's say we have a API for creating Users. We could generate a TypeScript SDK, and user won't have to write any URLs or anything. All user would do is:

import UsersApi from 'my-sdk';
UsersApi.create({
    id: null,
    first_name: 'Something',
    last_name: 'anything but something',
    email: '[email protected]'
}).then(data => {
    console.info("User created: ", data);
}).catch(err => {
    console.error("Something wrong:" , err);
})

We could let users to hook some sort of adapters so they can generate SDK for any language, not just for JavaScript/TypeScript

How I see the flow:
I want a User's creation endpoint:
I define what kind of data will be transferred, implement everything needed, then finally generate the SDK, use it in client's end.

I could send a PR with a rough POC for this one, since I'm not too much into these things, my way might not be the best, but we together can review and discuss about which way would be the best

Is there a way to remove the "Controller" suffix?

I know in phalcon we can remove the "Controller" suffix, I'm not sure about that in this project, is there anyway I can get the underlying dispatcher and set it? Since we've got pretty good namespace, we really don't have to worry about having a "Controller" suffix! I'm not requesting to remove it, I'm just requesting the option to remove the suffix.

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.