spiral / app

Spiral Framework Skeleton HTTP Application: Queue, Console, Cycle ORM
https://spiral.dev/
MIT License
191 stars 20 forks source link

Getting error when running seed #15

Closed sujit-baniya closed 4 years ago

sujit-baniya commented 4 years ago

I created command using following command:

php app.php create:command seed\account seed:account

then used following command to create entity

php app.php create:entity account -f id:primary name:string -e

Then I ran php app.php configure

Then update AccountCommand as:

protected function perform(TransactionInterface $tr, Generator $faker): void
    {
        for ($i = 0; $i < 100; $i++) {
            $user = new Account();

            $tr->persist($user);
        }

        $tr->run();
    }

When I tried to run php app.php seed:account, I'm getting following error:

 [Cycle\ORM\Exception\ORMException]               
 Unable to resolve role of `App\Database\Account` 
in /Users/sujit/Sites/labs/php/spiral-demo/vendor/cycle/orm/src/ORM.php:112

I'm getting above error on freshly installed https://github.com/spiral/demo

Why am I getting this error? Isn't there any resource to learn the framework easily?

Getting hard to understand the errors

wolfy-j commented 4 years ago

Hi,

you have missed the step to actually generate the migration (https://spiral.dev/docs/cycle-commands).

Try running

$ php app.php cycle:migrate

It will generate the migration for your entity in app/migrations and you can run it using php app.php migrate.

wolfy-j commented 4 years ago

I apologize for the hard learning curve, we learning how to simplify docs as we go.

sujit-baniya commented 4 years ago

No worries at all! :) I think it would be good to provide more error information

I got this error:

 [Cycle\ORM\Exception\ORMException]               
 Unable to resolve role of `App\Database\Account` 
in /Users/sujit/Sites/labs/php/spiral-demo/vendor/cycle/orm/src/ORM.php:112

And I don't know how to proceed ahead. It would be helpful to me if there was already resolve issue on github :)

But it's working now... I find this framework promising. I just need to get my hands dirty for my next project with this framework.

If possible can you suggest me how to deploy this framework to production with roadrunner

sujit-baniya commented 4 years ago

Now getting this error when trying to access localhost:8080 from browser:

Spiral \ Encrypter \ Exception \ EncrypterException
Encoding::hexToBin() input is not a hex string.
Previous exceptions
Encoding::hexToBin() input is not a hex string. (0)
wolfy-j commented 4 years ago

Weird, did you installed the application via composer create/application?

Check https://spiral.dev/docs/security-encrypter#application-key sounds like you have no encryption key.

sujit-baniya commented 4 years ago

It was working with ENCRYPTER_KEY={encrypter-key} previously

wolfy-j commented 4 years ago

I assume you set some cookies since the app configured to encrypt your cookies automatically. The error won't fire until the component used.

sujit-baniya commented 4 years ago

I did added Entity and Commands and ran some commands : cycle:migrate no other changes..

sujit-baniya commented 4 years ago

I think I found the issue but don't know how to resolve it.

Issue: I ran https://github.com/avto-dev/roadrunner-laravel on same port: 8080 then stopped it and ran the spiral framework... Then I encountered the issue again.

The env var was: ENCRYPTER_KEY={encrypter-key}

on spiral

krwu commented 4 years ago

try

$ php app.php encrypt:key -m .env

for spiral application.

sujit-baniya commented 4 years ago

With above command it's working