I have began to study "Laravel". I have already learned ruby on rails framework. Rails have console where you can create models and run all the commands your script runs. It is very useful and i am really used to this. I am interested if "Laravel" has anything like this, to create my objects and check if validations work correctly or run commands like "Post.all" where post is my object to retrieve all data from database.
Asked
Active
Viewed 1,517 times
1
-
3Are you maybe looking for Artisan CLI? https://laravel.com/docs/5.0/artisan – admcfajn Jan 24 '19 at 19:17
-
yes i think that is what i have been looking for but i have another problem. when i try to access to my objects for example Post it says that it is undefined. can you give me a solution for that? – ditojanelidze Jan 24 '19 at 20:47
-
@ditojanelidze are you using the full namespace of the class? – khartnett Jan 24 '19 at 21:02
-
1depending on how your classes are set up, try `\App\Post::all()` – khartnett Jan 24 '19 at 21:09
1 Answers
3
The Rails console is based on Interactive Ruby Shell (IRB) which is a read–eval–print loop (REPL) environment. There is an equivalent in Laravel (based off of psysh):
php artisan tinker
Note that 'Tinker' appears to be included in Laravel 5.7 (current at time of writing), but was removed in some previous versions. It can be installed with these instructions: https://stackoverflow.com/a/41888190/1512654

khartnett
- 831
- 4
- 14