This repository was archived by the owner on Jun 23, 2024. It is now read-only.
forked from navitronic/psymf
-
-
Notifications
You must be signed in to change notification settings - Fork 31
This repository was archived by the owner on Jun 23, 2024. It is now read-only.
Usage examples #73
Copy link
Copy link
Open
Description
Hi there,
I was looking for more in-depth documentation, a wiki page, or other usage examples. I've searched StackOverflow for the bundle's name and looked at closed issues, but I couldn't find any more help on how to use this package apart from the seemingly old screenshot included in the readme.
I come from a Laravel background and my goal is to find a suitable alternative for Laravel artisan tinker in Symfony.
How can I access my application's code in PsyshBundle?
Here are my tries in the console. I obviously have a User entity and plenty of repositories, but it seems I cannot access or even locate them. Could you please help me with some configuration and usage examples?
bin/console psysh
<aside>Psy Shell v0.10.12 (PHP 7.4.26 — cli) by Justin Hileman</aside>
New version is available (current: v0.10.12, latest: v0.11.4)
>>> $container;
=> Symfony\Bundle\FrameworkBundle\Test\TestContainer {#909}
>>> $user = new User();
PHP Error: Class 'User' not found in Psy Shell code on line 1
>>> $container->get(EntityManagerInterface::class);
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with message 'You have requested a non-existent service "EntityManagerInterface".'
>>> $container->get('doctrine')->getManager();
=> EntityManager_9a5be93 - Doctrine\ORM\EntityManager@proxy {#3016}
>>> $em = $container->get('doctrine')->getManager();
=> EntityManager_9a5be93 - Doctrine\ORM\EntityManager@proxy {#3016}
>>> $em->getRepository('UserRepository');
Doctrine\Persistence\Mapping\MappingException with message 'Class 'UserRepository' does not exist'
>>> $em->getRepository('App:Repository:UserRepository');
Doctrine\ORM\Exception\UnknownEntityNamespace with message 'Unknown Entity namespace alias "App"'
>>> $em->getRepository('App\Repository\UserRepository');
Doctrine\Persistence\Mapping\MappingException with message 'The class 'App\Repository\UserRepository' was not found in the chain configured namespaces App\Entity, Money'
>>> $em->getRepository('\User');
Doctrine\Persistence\Mapping\MappingException with message 'Class '\User' does not exist'
>>> $em->getRepository('User');
Doctrine\Persistence\Mapping\MappingException with message 'Class 'User' does not exist'
>>> $em->list();
PHP Error: Call to undefined method EntityManager_9a5be93::list() in Psy Shell code on line 1
>>> help
RuntimeException with message 'Too many arguments, expected arguments "command" "command_name".'
>>> $em
=> EntityManager_9a5be93 - Doctrine\ORM\EntityManager@proxy {#3016}
Metadata
Metadata
Assignees
Labels
No labels