Giter Club home page Giter Club logo

opulence's People

Contributors

adamaltman avatar alchimik avatar creocoder avatar dac514 avatar davidbyoung avatar harikt avatar jethom2 avatar nikic avatar peteraba avatar scaleddynamics avatar xaben avatar

Stargazers

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

Watchers

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

opulence's Issues

unambiguous migration ordering during running migrations:down

Issue description

The executedmigrations table will contain the datetime of the execution in the daterun column and this would be then used for finding the latest executed migration if you ran ./apex migrations:down. The problem is, if you ran previous migrations at once before, this will not provide a sufficient way to select the latest migration run. Instead it will pick a random one executed in the exact second of the truly last executed one.

Example

Code

namespace AbterPhp\Users\Databases\Migrations;
// ...
class Init extends Migration
{
    // ...
    public static function getCreationDate(): DateTime
    {
        return DateTime::createFromFormat(DateTime::ATOM, '2019-02-28T21:00:00+00:00');
    }
    // ...
}
namespace AbterPhp\Pages\Databases\Migrations;
// ...
class Init extends Migration
{
    // ...
    public static function getCreationDate(): DateTime
    {
        return DateTime::createFromFormat(DateTime::ATOM, '2019-02-28T21:01:00+00:00');
    }
    // ...
}
namespace AbterPhp\Files\Databases\Migrations;
// ...
class Init extends Migration
{
    // ...
    public static function getCreationDate(): DateTime
    {
        return DateTime::createFromFormat(DateTime::ATOM, '2019-02-28T22:00:00+00:00');
    }
    // ...
}
namespace AbterPhp\Contact\Databases\Migrations;
// ...
class Init extends Migration
{
    // ...
    public static function getCreationDate(): DateTime
    {
        return DateTime::createFromFormat(DateTime::ATOM, '2019-02-28T23:00:00+00:00');
    }
    // ...
}

Database

migration daterun
AbterPhp\Users\Databases\Migrations\Init 2019-03-04 12:03:43
AbterPhp\Contact\Databases\Migrations\Init 2019-03-04 12:03:44
AbterPhp\Files\Databases\Migrations\Init 2019-03-04 12:03:44
AbterPhp\Pages\Databases\Migrations\Init 2019-03-04 12:03:44

It may any of the last 3 for migrate:down.

Incomplete list of potential fixes

  1. Replace daterun column with a time format which will contain some high resolution time. (Backwards compatible, but requires a schema upgrade)
  2. Store the getCreationDate in a column and use that as a second sorting parameter when selecting the "last run" migration.
  3. Retrieve all migrations run at the same time as the "last" one and select the migration with the latest getCreationDate returned. (Backwards compatible and no schema upgrade necessary, but he query will be somewhat harder to understand, and could lead to problems if someone changes the getCreatedAt value of a migration.)
  4. Sleep 1 second before executing consecutive schema upgrades. ๐Ÿ˜„

Note: Using microseconds as high resolution time is probably enough in most cases although it might just make it harder to reproduce the issue. Giving an option to use hrtime instead could have benefits, but only doable in PHP at the moment afaik. (https://pecl.php.net/package/hrtime, http://php.net/manual/en/function.hrtime.php) Without hrtime precision it might make sense to combine more solutions too.

Migration

I'm going through documentation, maybe i'm missing something but i guess there is not migration tool?

Interacting with the schema using QueryBuilder

Do you have any interest in expanding the query builder to add the functionality necessary to interact with and modify the database schema? If not, is it because you believe using DDL is a better practice?

`composer update` after `apex app:rename Project [new_name] causes :flushcache to fail.

Ran across this situation while testing.

Conditions:
Fresh composer create-project...
apex app:rename Project [new_name]
composer update

Failure Dump:

PHP Fatal error:  Uncaught Error: Class 'Project\Application\Bootstrappers\Events\DispatcherBootstrapper' not found in /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/BootstrapperRegistry.php:109
Stack trace:
#0 /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/Dispatchers/Dispatcher.php(87): Opulence\Bootstrappers\BootstrapperRegistry->resolve('Project\\Applica...')
#1 /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/Dispatchers/Dispatcher.php(61): Opulence\Bootstrappers\Dispatchers\Dispatcher->dispatchEagerly(Object(Opulence\Bootstrappers\BootstrapperRegistry), Array)
#2 /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/ApplicationBinder.php(83): Opulence\Bootstrappers\Dispatchers\Dispatcher->dispatch(Object(Opulence\Bootstrappers\BootstrapperRegistry))
#3 [internal function]: Opulence\Bootstrappers\ApplicationBinder->Opulence\Bootstrappers\{closure}()
#4 /Volumes/Sam/dev/opulence in /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/BootstrapperRegistry.php on line 109

Fatal error: Uncaught Error: Class 'Project\Application\Bootstrappers\Events\DispatcherBootstrapper' not found in /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/BootstrapperRegistry.php on line 109

Error: Class 'Project\Application\Bootstrappers\Events\DispatcherBootstrapper' not found in /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/BootstrapperRegistry.php on line 109

Call Stack:
    0.0001     362352   1. {main}() /Volumes/Sam/dev/opulence/project/apex:0
    0.0003     370280   2. require_once('/Volumes/Sam/dev/opulence/project/bootstrap/console/start.php') /Volumes/Sam/dev/opulence/project/apex:3
    0.0061    1158416   3. Opulence\Applications\Application->start() /Volumes/Sam/dev/opulence/project/bootstrap/console/start.php:72
    0.0061    1158416   4. Opulence\Applications\Tasks\Dispatchers\Dispatcher->dispatch() /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Applications/Application.php:106
    0.0061    1158416   5. call_user_func:{/Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Applications/Tasks/Dispatchers/Dispatcher.php:34}() /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Applications/Tasks/Dispatchers/Dispatcher.php:34
    0.0061    1158416   6. Opulence\Bootstrappers\ApplicationBinder->Opulence\Bootstrappers\{closure}() /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Applications/Tasks/Dispatchers/Dispatcher.php:34
    0.0063    1173240   7. Opulence\Bootstrappers\Dispatchers\Dispatcher->dispatch() /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/ApplicationBinder.php:83
    0.0065    1197544   8. Opulence\Bootstrappers\Dispatchers\Dispatcher->dispatchEagerly() /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/Dispatchers/Dispatcher.php:61
    0.0065    1197600   9. Opulence\Bootstrappers\BootstrapperRegistry->resolve() /Volumes/Sam/dev/opulence/project/vendor/opulence/opulence/src/Opulence/Bootstrappers/Dispatchers/Dispatcher.php:87

Routing

Hi,
is there a way to define super simple route such as :controller/[/:action] ?

Discuss moving middleware to routing library

Currently, middleware is in the Http library. However, it seems to be more of a routing component. The routing library currently relies on the Http library because Opulence disagrees with PSR7's implementation. If Opulence ever moves to a standard request/response library, the only library that should be affected is the routing library. So, I am proposing moving middleware from the Http library to the routing library. A bonus would be that the only dependency the routing library would have is the closure serialization library.

What does everyone think?

Required PHP Extensions

It might be worth considering updating the documentation to list all required PHP extensions. For example, ctype is required and causes a Opulence\Debug\Errors\FatalThrowableError to be thrown if not loaded. So far, here's a list of extensions required (including those required for composer):

  • ctype
  • dom
  • filter
  • hash
  • json
  • mbstring
  • openssl
  • phar
  • session
  • tokenizer
  • xml

Spaces in Path cause passthru to fail for runlocally (possibly others)

A space in the Windows Path for PHP will cause the run to fail. Secondary to this issue, no error is reported when running this command.

Paths such as:

c:\Program Files\PHP\7.1\php.exe will result in:

Running at http://localhost:80
'c:\Program' is not recognized as an internal or external command, operable program or batch file.

To reproduce:

Place php in a path on Windows with a space in the path.

To fix:

Test for Windows, test for spaces, encapsulate command path in quotations.

Doesn't work on Windows

This doesn't work on Windows.

It requires a php extension ext-pcntl which is not available on Windows.

Could have let us know in the Readme

Nice FW but too many dependency

I have finished studying the documentation and I repeat what I have already said; nice framework and done well and easy to use.

Unfortunately, 35 dependency (28 or 29 only for phpunit) are too many for me (i hate composer) and I'm not going to use Opulence.

If you can make a version without composer I'll be happy to use it otherwise I wish you good luck, you deserve it, but I'm looking for something else.

Remove deprecated method(s) for forward compatibiltiy

In the RFC for 7.2 deprecations, the each method was listed as one of the functions/language constructs to be removed in a future PHP version.

I see the function being used in the Lexer for fortune.
Relevant links -

Since this would throw a deprecated notice, i think it's best to be cleaned up before a general release of the next version.

Nice work though

Failed opening required '/autoload.php'

Hi,

After installing opulence using composer as mentioned in doc. I tried to rename the app name using command given in doc as below

php apex app:rename Project NEW_NAME

Below is the error i am getting :

[leela@ip-centosami project]$ ls
apex bootstrap composer.json config phpunit.xml public resources src tests tmp
[leela@ip-centosami project]$ php apex app:rename project genius
PHP Warning: require(/autoload.php): failed to open stream: No such file or directory in /var/www/app1/project/config/paths.php on line 123 PHP Fatal error: require(): Failed opening required '/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/app1/project/config/paths.php on line 123
[leela@ip-centosami project]$

Am I missing anything in installation of the project ?

apex app:rename accepts bad input, breaks project

I ran:

php apex app:rename Project ms-payment

and the project was renamed, returned success, but it created code such as:

use ms-payment\Application\Bootstrappers\Cache\RedisBootstrapper;
use ms-payment\Application\Bootstrappers\Databases\SqlBootstrapper;

This triggers PHP Parse error: syntax error, unexpected '-', expecting ',' or ';'

Expected: Stop me from using a bad name.

Command Confirmation

I still review the code and I don't know where you like more to add this so I post directly a issue to track the idea:

I see the command shell and I missed one important note: where is the confirmation keys? Example:

Are you sure you want to rename Project to NewProject?

Ok im not a monkey so I thinking to use Y or N but I think is much better to put this 2 keys from default and happen example:

Are you sure you want to rename Project to NewProject? [y/n]

Or something you like ๐Ÿ‘

phpDocumentor problem

Nice framework but unfortunately phpDocumentor does not read the IO\Stream folder probably because Opulence uses reserved names or because it does not support: void as return value.

Unfortunately I do not know the reason.

Could you resolve please?

Thank you

[FEATURE] QueryBuilder::whereIn

It would be nice if the query builder supported a whereIn function, along with orWhereIn. This is something I miss quite often also in other frameworks.

Example usage:

use Opulence\QueryBuilders\PostgreSql\QueryBuilder;

$query = (new QueryBuilder)->select("id", "name", "email")
    ->from("users")
    ->whereIn("id", [1, 2, 3])
    ->orWhereIn("email", ["[email protected]", "[email protected]"]);
echo $query->getSql();

This would output:

SELECT id, name, email FROM users WHERE id IN (?, ?, ?) OR email IN (?, ?)

I wouldn't mind giving implementing this a shot, the only question is whether this should default to using named or unnamed parameters. Perhaps it could default to unnamed, with an optional parameter to use named parameters? I'd like to hear what you think.

Publish a coding standards document

Hi, great project.

Your code is very consistent but doesn't always match Symfony / PSR style. For example: Use of double quotes instead of single quotes even though there is no "$var" inside the string, single line PHPDoc comments for class properties, ...

It would be nice if you could publish a document explaining what style you expect contributors to adhere to.

Bonus points if I could import it into PHPStorm.

Thanks.

screenshot from 2017-01-10 11-06-58

Ioc container. Remove 'Reference Parameter' support

// PHP forces a reference operator when passing parameters by reference via an array
if ($parameter->isPassedByReference()) {
$resolvedParameters[] = &$resolvedParameter;
} else {
$resolvedParameters[] = $resolvedParameter;
}

1. it doesn't work

I checked: HEAD, v1.0.0, v1.0.0-rc2

1.1 test is wrong

ContainerTest::testResolvingClassWithReferenceParameter should be something like:

public function testResolvingClassWithReferenceParameter()
{
    // preparing
    $bar = new Bar();
    $this->container->bindInstance($this->fooInterface, $bar);
    /** @var ConstructorWithReference $instance1 */
    $instance1 = $this->container->resolve($this->constructorWithReference);
    /** @var ConstructorWithReference $withRef2 */
    $instance2 = $this->container->resolve($this->constructorWithReference);
    $this->assertInstanceOf($this->constructorWithReference, $instance1);
    $this->assertInstanceOf($this->constructorWithReference, $instance2);
    $this->assertNotSame($instance1, $instance2);
    $this->assertSame($instance1->getFoo(), $instance2->getFoo());

    // start useful check
    $instance1->setFoo(new Bar());
    $this->assertSame($instance1->getFoo(), $instance2->getFoo());
    $instance2->setFoo(new Bar());
    $this->assertSame($instance1->getFoo(), $instance2->getFoo());
}

2. other containers don't support this

  • illuminate/container
  • symfony/dependency-injection
    but I could be wrong

3. this is a really dangerous feature (imho)

How to add a view part

I tried to make a fix for the home page because missing the content part for make inside the errors generated by views but nothing happen, I follow the docs but without success, I have tried some ways (added show).

This is my source:

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="initial-scale=1" />
        {{! charset("utf-8") !}}
        {{! pageTitle($title) !}}
        {{! css("http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,300,400,700") !}}
        {{! css($css) !}}
        <link rel="icon" type="image/png" href="/favicon-32x32.png?v=1.0" sizes="32x32">
        <link rel="icon" type="image/png" href="/favicon-16x16.png?v=1.0" sizes="16x16">
    </head>
    <body>
        <main class="main">
            <% part("content") %>
            <div id="welcome-wrapper">
                <section id="welcome">
                    <h1>Welcome</h1>
                    You just successfully created your first Opulence application. That wasn't too hard, was it?
                </section>
                <section id="learn-more">
                    <h3>Learn More</h3>
                    Read the <a href="https://www.opulencephp.com/docs/installing" target="_blank" title="Read the official documentation">official documentation</a>.
                </section>
            </div>
            <% endpart %>
        </main>
    </body>
</html>

Issues updating after a rename (alpha-22 and up)

Reproduction steps:

  1. Create a new project
  2. Rename it
  3. Watch your world a-splode

[RuntimeException]
Error Output: PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Boots
trappers/Caching/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 78
PHP Warning: Illegal string offset 'target' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers/Cachi
ng/FileCache.php on line 82
PHP Warning: Illegal string offset 'bootstrapper' in /var/www/html/vendor/opulence/opulence/src/Opulence/Bootstrappers
/Caching/FileCache.php on line 83
PHP Fatal error: Uncaught exception 'Opulence\Ioc\IocException' with message 'Opulence\Views\Caching\ICache is not ins
tantiable' in /var/www/html/vendor/opulence/opulence/src/Opulence/Ioc/Container.php:171
Stack trace:
#0 /var/www/html/vendor/opulence/opulence/src/Opulence/Ioc/Container.php(221): Opulence\Ioc\Container->make('Opulence
Views...', false, NULL, Array, Array)
#1 /var/www/html/vendor/opulence/opulence/src/Opulence/Ioc/Container.php(558): Opulence\Ioc\Container->makeShared('Opul
ence\Views...')
#2 /var/www/html/vendor/opulence/opulence/src/Opulence/Ioc/Container.php(388): Opulence\Ioc\Container->resolveClass('Op
ulence\Framew...', 'Opulence\Views...', false)
#3 /var/www/html/vendor/opulence/opulence/src/Opulence/Ioc/Container.php(186): Opulence\Ioc\Container->getResolvedParam
eters('Opulence\Framew...', Array, Array, false)
#4 /var/www/html/vendor/opulence/opulence/src/Opulence/Ioc/Container.php(221): Opulence\Ioc\Container->make('Opulence
Framew...', false, NULL, Array, Array)
#5 /var/www/html/vendor/opul in /var/www/html/vendor/opulence/opulence/src/Opulence/Applications/Tasks/Dispatchers/Disp
atcher.php on line 37

\Opulence\Memcached\Memcached methods do not autocomplete in IDE

Copying the example located here:

I noticed that:

$memcached->set('foo', 'bar');
echo $memcached->get('foo'); // "bar"

Are marked as "method not found" in PHPStorm because they use __call(). The documentation for that class seems to imply that I can use any Memcached library i'd like. How many libraries are there other than \Memcached and \Memcache? How different are the implementations from each other?

Feature requests:

It would be nice to PHPDoc common methods. See:

How to get autocomplete for magic method __call:

It would be nice that the \Opulence\Memcached\Memcached documentation linked to (and encouraged the use of?) Memcached Bridge because if a user stumbles on that page from a search engine maybe they won't know about it.

Similar issues for \Opulence\Redis\Redis

Add dates to changelog

It would be great if you could include release dates in the changelog so that people don't have to dig through the git history to determine when a particular release occurred.

Data Mapper command doesn't handle namespaces

Using php apex make:datamapper Shop\\Product as a SQL mapper I expect {app}/app/project/orm/Shop/Product.php to be created. Instead {app}/app/project/orm/ShopProduct.php is the file created. This means your ORM directory is going to get crazily huge on larger projects.

The datamapper creation command should be able to handle namespaces and create the required folder structure for auto-loading.

IP Address isn't Set Correctly on Gogo Inflight Wifi

The following exception is thrown when attempting to set the IP address when connected to Gogo inflight wifi:

[Tue Oct 25 06:40:46.203568 2016] [:error] [pid 30215] [client 12.130.117.27:60694] [2016-10-25 10:40:46] application.ERROR: InvalidArgumentException: Invalid host "172.19.131.152, 10.33.185.152" in /var/www/html/project/vendor/opulence/opulence/src/Opulence/Http/Requests/Request.php:399 Stack trace: #0 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Http/Requests/Request.php(345): Opulence\Http\Requests\Request->getHost() #1 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Framework/Http/Middleware/Session.php(63): Opulence\Http\Requests\Request->getFullUrl() #2 [internal function]: Opulence\Framework\Http\Middleware\Session->handle(Object(Opulence\Http\Requests\Request), Object(Closure)) #3 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Pipelines/Pipeline.php(116): call_user_func_array(Array, Array) #4 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Framework/Http/Middleware/CheckMaintenanceMode.php(42): Opulence\Pipelines\Pipeline->Opulence\Pipelines{closure}(Object(Opulence\Http\Requests\Request)) #5 [internal function]: Opulence\Framework\Http\Middleware\CheckMaintenanceMode->handle(Object(Opulence\Http\Requests\Request), Object(Closure)) #6 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Pipelines/Pipeline.php(116): call_user_func_array(Array, Array) #7 [internal function]: Opulence\Pipelines\Pipeline->Opulence\Pipelines{closure}(Object(Opulence\Http\Requests\Request)) #8 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Pipelines/Pipeline.php(53): call_user_func(Object(Closure), Object(Opulence\Http\Requests\Request)) #9 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Framework/Http/Kernel.php(116): Opulence\Pipelines\Pipeline->execute() #10 /var/www/html/project/bootstrap/http/start.php(72): Opulence\Framework\Http\Kernel->handle(Object(Opulence\Http\Requests\Request)) #11 [internal function]: {closure}() #12 /var/www/html/project/vendor/opulence/opulence/src/Opulence/Applications/Application.php(102): call_user_func(Object(Closure)) #13 /var/www/html/project/bootstrap/http/start.php(74): Opulence\Applications\Application->start(Object(Closure)) #14 /var/www/html/project/public/index.php(7): require_once('/var/www/html/p...') #15 {main} [] []

Improve `make:entity` and `make:datamapper` by inferring the database schema (tables/columns/relationships) automatically.

Feature request: Improve make:entity and make:datamapper by inferring the database schema (tables/columns/relationships) automatically.

Assuming access to a database table and a sane schema, the make:entity and make:datamapper apex commands could stub out more of the code. Less tedious boiler plating for the developer.

Check out https://github.com/jamend/selective-orm for an ORM that can infer automatically.
(See: buildTable method for a way to extract data for MySQL, check the same source code dir for Sqlsrv and SQLite implementations as well)

Thanks!

Not proper use of prepare statements in the sql repository example on documtentation page

Hi there,

I have notice some kind of bug or performance issue:

In class Opulence\Orm\Repositories\Repository we can see:

    /**
     * @inheritdoc
     */
    public function add($entity)
    {
        $this->unitOfWork->scheduleForInsertion($entity);
    }

and it seem to be valid.

But I found in your documentation located at https://www.opulencephp.com/docs/1.0/orm-repositories that you propose following code:

    /** @var Post $post */
    public function add($post)
    {
        $statement = $this->writeConnection->prepare(
            'INSERT INTO posts (text, title, author) VALUES (:text, :title, :author)'
        );
        $statement->bindValues([
            'text' => $post->getText(),
            'title' => $post->getTitle(),
            'author' => $post->getAuthor()
        ]);
        $statement->execute();
    }

which seems to be wrong.

Let's imagine that you will need to add 100 posts:

$dataMapper = new PostSqlDataMapper();
// Assume $unitOfWork is already instantiated
$repo = new Repository(Post::class, $dataMapper, $unitOfWork);

for ($i=0; $i < 100; $i++) {
    $postToAdd = new Post($i, 'First Post', 'This is my first post');
    $repo->add($postToAdd);
}

$unitOfWork->commit();

I haven't tried it yet, but from my point of view you will make new prepare statement for each post, instead of make it once and values as many as you want.

Tutorial or More docs

Hello, first of all i am very interested in this new framework i think it will be the best... However the documentation is still poor and the lack of tutorials makes it difficult to understand. For example where is written how can i create model and what should i extend or implement. Some kind of tutorial about ORM will be very usefull. Thanks in advance. Wish all the best !

Restrict Choices for Encrypter's Ciphers

Currently, the encrypter class lets you select broken ciphers. I propose restricting the ciphers you're allowed to select. If a broken cipher is selected, an \InvalidArgumentException should be thrown.

Rewriting own SqlDataMapper classes

Your solution to use:

  • entity (not found an example)
  • dataMapper
  • repository
  • unit of work
// Assume $dataMapper and $unitOfWork are already instantiated
$repo = new Repository(Post::class, $dataMapper, $unitOfWork);

I cannot see how Post class look like - and this is quite important!

But the clue of this issue is to make some relations between repository to set in one place:

  • table name,
  • table columns,
  • make simple SQL resolver, which will automatically build SQL query.

Examples from documentation are quite simple so you can make new definitions of add(), delete(), update() methods, and if programmer would need to customize them he/she will override them with own methods (e.g. use only some of columns).

I know that writing complex ORM is not so easy, but I would help you to get more programmers using Opulence :)

Maintenance mode

Hello, I checked the maintenance mode and it's normal the view not change? I see only the page title get "Error" and nothing more.

I installed clean project and nothing change, only run php apex app:down command.

Thanks.

Questions

Hi David,

Tell me how I extend your Opulence src to provide custom cache implementations, like Memache (not Memcached) or other cache backends.

Running `php apex app:runlocally` in Ubuntu does not work

This was first brought up in #91. Apparently, Windows and Ubuntu differ in the directory that they're operating in when executing this command. So, we need to be able to specify the path to the router file through the command's constructor.

add reflection cache in IdAccessorRegistry::registerReflectionIdAccessors

https://github.com/opulencephp/Opulence/blob/1.0/src/Opulence/Orm/Ids/Accessors/IdAccessorRegistry.php#L81

    /**
     * @inheritdoc
     */
    public function registerReflectionIdAccessors($classNames, string $idPropertyName)
    {
        foreach ((array)$classNames as $className) {
            $this->registerReflectionIdAccessor($className, $idPropertyName);
        }
    }

something like this:

    private function registerReflectionIdAccessor($className, string $idPropertyName)
    {
        try {
            $reflectionClass = new ReflectionClass($className);
            $property = $reflectionClass->getProperty($idPropertyName);
            $property->setAccessible(true);
        } catch (ReflectionException $ex) {
            throw new OrmException("to_do");
        }

        $getter = function ($entity) use ($property) {
            return $property->getValue($entity);
        };
        $setter = function ($entity, $id) use ($property) {
            $property->setValue($entity, $id);
        };
        $this->registerIdAccessors($className, $getter, $setter);
    }

or this:

    private function registerReflectionIdAccessor($className, string $idPropertyName)
    {
        $getProperty = function () use ($className, $idPropertyName) {
            static $property;

            if (null === $property) {
                $reflectionClass = new ReflectionClass($className);
                $property = $reflectionClass->getProperty($idPropertyName);
                $property->setAccessible(true);
            }

            return $property;
        };

        $getter = function ($entity) use ($getProperty) {
            return $getProperty()->getValue($entity);
        };
        $setter = function ($entity, $id) use ($getProperty) {
            $getProperty()->setValue($entity, $id);
        };
        $this->registerIdAccessors($className, $getter, $setter);
    }

But I'm not sure it's necessary.

Suggestion: Add option to clear console cache for apex

One thing I learned is that there's a cache file for console that almost instantly gets cached in tmp/framework/console called cachedBootstrapperRegistry.json and say if you remove a bootstrap class it'll throw a fatal error making apex compeltely unusable because it's looking for a class that doesn't exist anymore.

My suggestion is to be able to call: php apex --hard-cache-clear which does one thing and that's to clear the cache directly and nothing else that way you won't have to manually do it to get apex working again.

I'm still learning Opulence, so maybe I'll try creating a PR if I figure it out tonight.

Why $fallBackToUniversalBindings === false in Opulence\Ioc\Container::hasBinding?

https://github.com/opulencephp/Opulence/blob/1.0/src/Opulence/Ioc/Container.php#L139

$container = new Container();
class Foo {}
$interface = "interface";
$container->bindInstance($interface, new Foo);
$container->for("foo", function (IContainer $container) use ($interface) {
     var_dump($container->hasBinding($interface));         // false
     var_dump(get_class($container->resolve($interface))); // 'Foo'
});

hasBinding === false, but we can resolve anyway. I think it's weird.

Environment setup is extremely confusing.

The entire environment setup is quite confusing to use. While it is possible to integrate it with other tools such as phinx, it isn't easy nor convenient.

Dotenv is a fantastic package maintained by Vance that provides a seamless environment configuration experience. Simple to use and share between tooling.

Could a move to using Dotenv be considered? Taking advantage of it will provide the best experience to developers.

Get Matched Route in Middleware

Since middleware is called from Opulence\Framework\Http\Kernel::handle() before routing takes place, I don't believe there's an elegant way to obtain the matched route in middleware.

I propose that a new method Opulence\Routing\Router::match() be created and that Opulence\Routing\Router::route() be refactored to make use of Opulence\Routing\Router::match().

As a practical example, one would be able to obtain the controller name through middleware using the following:

class MyMiddleware implements IMiddleware
{
    private $router;

    public function __construct(Router $router)
    {
        $this->router = $router;
    }

    public function handle(Request $request, Closure $next) : Response
    {
        $controller = $this->router->match($request)->getControllerName();

        /* Do something with $controller... */

        return $next($request);
    }
}

Rename command changes folder name

When executing php apex app:rename Project App the folder project is renamed app. This shouldn't happen. PSR-4 will work just fine if App is contained with the project folder. The folder-name shouldn't change since all that does is create needless git changes to track that add no benefit.

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.