Tinker with your local/remote PHP (Laravel, Magento) Code

I was always looking for a quick playground for testing/debugging any PHP application esp. for Magento 2.

Luckily, I got to know about Tinkerwell App in some twitter feed and thought of giving a try.


This content originally appeared on DEV Community and was authored by Raj KB

I was always looking for a quick playground for testing/debugging any PHP application esp. for Magento 2.

Luckily, I got to know about Tinkerwell App in some twitter feed and thought of giving a try.

If you don’t know about Tinerwell app

Tinkerwell is the magical code editor that runs your code within local and remote PHP applications. In other words, it’s a RELP(read-eval-print loop) for PHP.

Though there are some tools like:

But the main advantage of the Tinkerwell app over others is that it can tinker locally and also remotely(via SSH).
Also, it has official IDE plugins so that you can run code directly from your favorite code editor(VSCode, Sublime Text 3 and PhpStorm).

Installation

Tinkerwell is a commercial app that only costs around 15 USD and really worth it.

After purchasing, you will get an email with a link to download the app along with the license key.
image

After downloading you can simply install the installer file and configure the License Key, so nothing fancy about it.

Configuring for Magento 2

Currently(as the time of writing), the major PHP applications supported by Tinkerwell app are:

  • Magento 2
  • Laravel
  • Symfony
  • WordPress
  • Drupal
  • Typo3
  • Prestashop

The full list can be found at – https://github.com/tinkerwellapp/drivers

Tinkerwell “drivers” determine how the application should be bootstrapped – and can even provide variables that should be available automatically.

Since Magento 2 is supported by default, you just need to set the working directory in local or remote.

Tinkering with Magento 2 Locally

Open the app and click on the folder icon (1) and set your local Magento 2 working directory(2). That’s it.

image

Now, you can run/debug any Magento 2 code (core & custom) with the realtime preview on the right pane. For example, it may look like

image

Running code with Tinkerwell

image

Running selected code in PHPStorm with Tinkerwell

$objectManager variable is available by default (via Magento 2 driver)

Troubleshooting

Problem: If you are getting an error

Zend_Db_Adapter_Exception with message ‘SQLSTATE[HY000] [2002] No such file or directory’

Solution: Just replace ‘localhost’ by the IP address(127.0.0.1) for DB host in the file app/etc/env.php

Tinkering with Magento 2 Remotely (via SSH)

For remote interactive debugging, you can connect via Action (1) > Connect Via SSH. You will see a similar popup as below:

image
Just fill-up the SSH login details and connect(2). Now you are able to able to run the code in remote.

Conclusion

Though there are some alternatives, Tinkerwell works quite well locally and remotely for testing out any PHP code (not only limited to Laravel, Magento 2 or other PHP frameworks).
It’s really quite helpful in quick testing/debugging any PHP code and saves a lot of time.

You might be interested in following Twitter discussion:


This content originally appeared on DEV Community and was authored by Raj KB


Print Share Comment Cite Upload Translate Updates
APA

Raj KB | Sciencx (2021-06-17T21:08:46+00:00) Tinker with your local/remote PHP (Laravel, Magento) Code. Retrieved from https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/

MLA
" » Tinker with your local/remote PHP (Laravel, Magento) Code." Raj KB | Sciencx - Thursday June 17, 2021, https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/
HARVARD
Raj KB | Sciencx Thursday June 17, 2021 » Tinker with your local/remote PHP (Laravel, Magento) Code., viewed ,<https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/>
VANCOUVER
Raj KB | Sciencx - » Tinker with your local/remote PHP (Laravel, Magento) Code. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/
CHICAGO
" » Tinker with your local/remote PHP (Laravel, Magento) Code." Raj KB | Sciencx - Accessed . https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/
IEEE
" » Tinker with your local/remote PHP (Laravel, Magento) Code." Raj KB | Sciencx [Online]. Available: https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/. [Accessed: ]
rf:citation
» Tinker with your local/remote PHP (Laravel, Magento) Code | Raj KB | Sciencx | https://www.scien.cx/2021/06/17/tinker-with-your-local-remote-php-laravel-magento-code/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.