Closed sujit-baniya closed 4 years ago
Can you run ‘php app.php cycle’ to make sure that ORM schema generated?
I'm getting same error when trying to run above command
[Cycle\ORM\Exception\ORMException]
Unable to find Entity role for repository App\Repository\UserRepository
in /home/sujit/Sites/labs/php/go-php/vendor/spiral/framework/src/Cycle/RepositoryInjector.php:56
Can you show me the content of Post
entity? Did you set the repository on it?
Check the demo source code here: https://github.com/spiral/demo
Post.php
<?php
/**
* {project-name}
*
* @author {author-name}
*/
declare(strict_types=1);
namespace App\Database;
use Cycle\Annotated\Annotation as Cycle;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Cycle\Entity(repository = "App\Repository\PostRepository")
*/
class Post
{
/**
* @Cycle\Column(type = "primary")
*/
public $id;
/**
* @Cycle\Column(type = "string")
*/
public $title;
/**
* @Cycle\Column(type = "text")
*/
public $content;
/**
* @Cycle\Relation\BelongsTo(target = "User", nullable = false)
* @var User
*/
public $author;
/**
* @Cycle\Relation\HasMany(target = "Comment")
* @var ArrayCollection|Comment
*/
public $comments;
public function __construct()
{
$this->comments = new ArrayCollection();
}
}
Also I noticed that $this->users
is not detected: https://i.imgur.com/zxzyEWm.png
Also I noted that UserRepository is not used: https://i.imgur.com/ct8FmiI.png
Can you make sure that php app.php configure
executed?
See the list of installation commands at the bottom of this page - https://spiral.dev/docs/basics-quick-start#source-code
If everything is correct you should find runting/cache/cycle.php
file with the ORM schema. I just tested and the newly downloaded code works well.
I cloned the demo project. On demo project I can't run the server.
It's stuck here https://i.imgur.com/pzu8xn6.png
Per your screenshot, you are running the server. Try to open any page http://localhost:8080/posts?paginate[page]=2
(it will fail if you haven't run the migrations)
The server is not running at all: https://i.imgur.com/LNH7n1J.png
Hmm, is it possible that :8080
forbidden on your machine? Can you change the port in .rr.yaml
and try again? Do you run any other apps which use :8080
port?
other apps were not using 8080 port... I restarted by PC and it worked... So You used constructor to assign UserRepository...
But why the example from documentation didn't work? https://i.imgur.com/NUzVPsZ.png
The example did not work since prototype trait did not know about users
property (repository) until the app.php configure
executed.
I copied the Command files from your demo to my sample project. But still I'm getting the same error on my project..
I removed perform
on PostCommand and php app.php configure
and it works.
But if I replace it to use the content same as yours, it's still same issue
Can you please do me a favor to look over the demo project: https://github.com/itsursujit/go-php
I'm really unable to figure it out... I need to know why is it happening and find the possible solution.
This framework is promising but I need to debug it on why it's not working and possible solution for it before moving ahead.
Thanks
Weird, the code you provided works well for me. http://prntscr.com/rtwlsz
All the commands work and data seeded.
hmm... let me remove the project and re-clone it.
FYI, I'm using Ubuntu 18.04 LTS
Just tested it on Ubuntu and it works great.
Okay! After removal of project and reinstalling it. It worked... Don't know why it was not working before and now it's working.
I'll try to replicate the issue
Please let me know if you'll get the right order of actions to cause the issue.
Recommendation: if something weirdly does not work - remove runtime/cache
directory.
I tried to follow https://spiral.dev/docs/basics-quick-start I changed the
PostCommand
as mentioned in documentation to this:And I'm getting following error.
What am I doing wrong.