vulcan icon indicating copy to clipboard operation
vulcan copied to clipboard

Wrap `psysh` inside the command

Open david-sosa-valdes opened this issue 8 years ago • 7 comments

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

david-sosa-valdes avatar Jan 12 '17 21:01 david-sosa-valdes

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 avatar Jan 13 '17 03:01 lonnieezell

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

lonnieezell avatar Jan 16 '17 06:01 lonnieezell

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.

david-sosa-valdes avatar Jan 16 '17 19:01 david-sosa-valdes

Great! Glad that change worked.

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

lonnieezell avatar Jan 16 '17 20:01 lonnieezell

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:

  • Create object instances like: models, helpers, libraries, third_party, controllers, etc.
  • See the config variables in your application.
  • See the data in your database (using models).
  • Check class/function source.

Another features that i want to accomplish are:

  • Reading a function/class documentation
  • Test different config/environment variables
  • Display full error messages (--verbose --backtrace)

What do you think?

david-sosa-valdes avatar Jan 16 '17 21:01 david-sosa-valdes

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.

lonnieezell avatar Jan 19 '17 22:01 lonnieezell

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"

david-sosa-valdes avatar Mar 23 '17 23:03 david-sosa-valdes