A few months ago i discovered PHP-console. It’s a nice user interface with an eval() function that would take your PHP snippet and run it.

Most online PHP sandboxes out there works the same way, (there is also the PHP sandbox extension which i haven’t examine yet), with an extra layer of security since you don’t want users to be able to run any code they want.

After i saw PHP-console, Magento came immediately in my mind. I thought it would be cool to be able to run Magento API whenever i needed to test something. So, stargento.com was born.

Basically, it’s a single eval() with an ‘include Mage.php’ statement before.

Before i put the code into eval() i am examining it using token_get_all and comparing every token with a list of allowed and not tokens. This way i can prevent the execution of e.g. file system function calls.

It’s as simple as it looks, yet it has served me quite a lot since i am constantly looking to test some of the complicated Magento API.

I am looking forward for your comments. A feature that i think it would be great is auto saving to Github Gists and it’s already in it’s way.

Hope you liked it.

Leave me your comments here or at @kbariotis

My mission is to write clean and efficient code, to solve problems and for me to learn something more. http://kostasbariotis.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store