lonnieezell / vulcan

CLI tools for CodeIgniter 4
55 stars 11 forks source link

Wrap `psysh` inside the command #1

Open david-sosa-valdes opened 7 years ago

david-sosa-valdes commented 7 years ago

When we execute the console command like:

php public/index.php ci console

It's ok...the problem here is when we call it using the ci.php script like:

php ci.php console

Because it wraps the psysh\shell inside a passthru execution and makes it no operational.

I open a discussion to solve this problem on: https://github.com/bobthecow/psysh/issues/343

lonnieezell commented 7 years ago

I was a bit afraid of that. I have been thinking the whole bootstrapping process of CI needs to be looked at, since it was dealt with early on to get something to work with, and then another contributor put it in a class, but still doesn't feel right/elegant to me. Which would mean that, ideally, we wouldn't need to run through the index file, but just load up the CodeIgniter.php file and tell it to bootstrap.

We'll watch that discussion and see if anything helpful comes from it, but I'm not overly hopeful.

lonnieezell commented 7 years ago

I've just pushed some changes to the main CodeIgniter repo that should help with this: https://github.com/bcit-ci/CodeIgniter4/pull/367

david-sosa-valdes commented 7 years ago

Yes, the console command it's now operational and wrapped with CI. Now I think we need to define which are the use cases to see if it can correctly execute everything.

lonnieezell commented 7 years ago

Great! Glad that change worked.

To get us started, what use cases did you have implemented on Craftsman?

david-sosa-valdes commented 7 years ago

Craftsman has a simple logic, it only have one generic CI_Controller that can load all the core and user classes.

Some important features that Vulcan::console already accomplish correctly are:

Another features that i want to accomplish are:

What do you think?

lonnieezell commented 7 years ago

Yup, I think all of those are great! Very much looking forward to playing with those. :)

Only thing else that I can think off the top of my head is ensuring it's simple to use the debugger in Psysh, but I'm not sure if there's anything we need to do there.

david-sosa-valdes commented 7 years ago

As a matter of fact, i create a simple library that calls psysh in the CI application, all you need to do is include eval(\Vulcan\Libraries\Debugger::check()); in your script.

When your script reaches this point, execution will be suspended and you’ll be dropped into a PsySH shell. Your program state is loaded and available for you to inspect and experiment with.

But the problem here is exactly like when we run the CLI before the last updates of CI4. When you run:

php serve.php 

It wraps the psysh\shell inside a passthru execution and makes it no operational, so if you want to use it you must run a server instance with:

php -S localhost:8000 -t public/ rewrite.php"