# Debugging a Slim Back End with Different Front End

**URL:** <https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594>\
**Category:** Questions\
**Created:** [January 5, 2021, 7:56pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594 "2021-01-05T19:56:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeroenVunderink](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@JeroenVunderink](https://discourse.slimframework.com/u/JeroenVunderink)\
**Post date:** [January 5, 2021, 7:56pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/1 "2021-01-05T19:56:21Z")

</div>

Hi,

I’m new at this forum and hope someone can guide me in the right direction.

I’m building my website with an Angular front end and a Slim 4 back end. I use Rest Api’s to get data or post files to my back end from the Angular built front end. All work fine but I haven’t figured out how to debug my Slim Backend.

Till now I simply use Postman and echo back to debug but do not want to continue like that. So I hope someone can help me.

I develop on a Mac with VS Code/Angular and Netbeans/PHP (although I download PHPStorm also today to see their debug facilities and hope that will bring me further).

My front end runs on a locally defined webserver like “frontend.localhost.dev” and my Slim backend runs also locally defined webserver like “api.localhost.dev”. Both https but that doesn’t matter I believe.  
This is a copy of my “production” environment. I have deployed it to my provider and all works, so no issues there.

What I need if a “listener” (XDEBUG? ZEND?) in my PHP IDE that will enable Step by Step debugging when I run my frontend in the browser and execute my http requests. (Hope I explained it clearly enough)

Can anyone help me to guide me what to do, to select and how to configure (any) IDE to make this work? It’s fine to run a separate or internal webserver in the IDE next to my locally defined backend. My front end is easily to be redirected to an different server path.

I hope someone can help me.

Cheers,  
Jeroen

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [January 5, 2021, 11:39pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/2 "2021-01-05T23:39:12Z")

</div>

Learning [Xdebug](https://xdebug.org) was a game changer for me. The setup will vary wildly depending on the webserver and IDE you are using so you will likely need to find some tutorials specific to your environment. I tend to use [Bitnami](https://bitnami.com/stack/mamp) which comes with the Xdebug extension ready to go and VS Code for an editor/IDE. I hear the setup for Xdebug 3 is a little easier, but I’m still working with version 2.x.

---

<div class="post-metadata">

**Author:** ![JeroenVunderink](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@JeroenVunderink](https://discourse.slimframework.com/u/JeroenVunderink)\
**Post date:** [January 6, 2021, 7:04am UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/3 "2021-01-06T07:04:30Z")

</div>

Thanks for the reply. I haven’t use MAMP and have configured my Apache, MySQL etc all manual, including creating the https certificates. If I would now use MAMP Bitnami, is the overwriting my configuration? Of do I “just” get a GUI that recognises my current config and “just” makes it easier to maintain?

Next to this I understand that on a mac I have to install a “local” php version with or Homebrew of PECL, than download xdebug, phpist and make xdebug before setting up my IDE. Is that correct?

Thanks in advance for your reply.

---

<div class="post-metadata">

**Author:** ![tj\_gumis](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@tj\_gumis](https://discourse.slimframework.com/u/tj_gumis)\
**Post date:** [January 6, 2021, 10:59am UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/4 "2021-01-06T10:59:27Z")

</div>

Why don’t you use any logger ? This is the best way to be kept in touch with anything that happens on the api’s side. Look at one of Odan’s tutorials:

[Slim 4 - Logging](https://odan.github.io/2020/05/25/slim4-logging.html)

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [January 6, 2021, 1:20pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/5 "2021-01-06T13:20:29Z")

</div>

Logging can be useful, just as `dump` or `echo` can be. But a step debugger is often easier and less complicated to use, once setup.

You don’t need to use Bitnami for sure. It will not overwrite your existing PHP/MySQL setup at all. I personally just find it easier to keep a bunch of different PHP versions installed. I also use it some of my production environments which allows me to know that my dev environment is a very close match.

Your install steps sound correct to me, but I’ve never done it from scratch like that myself as Xdebug comes with the stack I use. You may want to check and see if you have the Xdebug extension already and perhaps it just needs to be turned on in your `php.ini`.

You can find your `php.ini` with a command like `php --ini` then look in there for any Xdebug configuration. `cat php.ini | grep -i xdebug` You may already have the extension but I don’t think it comes with PHP installed by macOS.

---

<div class="post-metadata">

**Author:** ![tj\_gumis](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@tj\_gumis](https://discourse.slimframework.com/u/tj_gumis)\
**Post date:** [January 6, 2021, 2:12pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/6 "2021-01-06T14:12:03Z")

</div>

> [@tflight](#):
>
> Logging can be useful, just as `dump` or `echo` can be.

Comparing dump/echo with logging is a kind of an abuse. As logging being indispensable for a production environment there is no reason not to relay on it during a development.  
Especially in case of APIs.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [January 6, 2021, 2:52pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/7 "2021-01-06T14:52:02Z")

</div>

If that approach works best for you, that is great! We all look at things from different angles and come from unique experiences with different goals. We can all learn.

I find logging helps _me_ figure out **what** happened, while a step debugger like Xdebug helps me figure out **why** something happened. I use all of these approaches to debug from time to time.

If someone whats to learn more debugging techniques from dump to logging to step debuggers, that is great!

---

<div class="post-metadata">

**Author:** ![tj\_gumis](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@tj\_gumis](https://discourse.slimframework.com/u/tj_gumis)\
**Post date:** [January 6, 2021, 2:55pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/8 "2021-01-06T14:55:46Z")

</div>

I am really glad you can see it this way. It is kind of rare attitude nowadays.  
Respect.

---

<div class="post-metadata">

**Author:** ![JeroenVunderink](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@JeroenVunderink](https://discourse.slimframework.com/u/JeroenVunderink)\
**Post date:** [January 7, 2021, 7:31am UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/9 "2021-01-07T07:31:47Z")

</div>

Thanks for the feedback. I fully agree that logging is nice and works but especially when creating more complex code, step by step debugging is for me a far better method to debug.

I the mean time I’m looking around to setup php with Homebrew, but that doesn’t work because running the latest version of Big Sur.

@tflight I also looked at Bitnami to do this instead of with Homebrew, but can’t find a as simple install for PHP under my user with this package. I do not want to install any other packages, I just want to setup PHP, PECL PHPIZE and XDEBUG.

The XDEBUG wizard tells me to do the follwoing:

1. Download [xdebug-3.0.2.tgz](http://xdebug.org/files/xdebug-3.0.2.tgz)
2. Install the pre-requisites for compiling PHP extensions.  
On your Mac, we only support installations with ‘homebrew’, and `brew install php && brew install autoconf` should pull in the right packages.
3. Unpack the downloaded file with `tar -xvzf xdebug-3.0.2.tgz`
4. Run: `cd xdebug-3.0.2`
5. Run: `phpize` (See the [FAQ](https://xdebug.org/docs/faq#phpize) if you don’t have `phpize` ).As part of its output it should show:

Configuring for: … Zend Module Api No: 20180731 Zend Extension Api No: 320180731

If it does not, you are using the wrong `phpize` . Please follow [this FAQ entry](https://xdebug.org/docs/faq#custom-phpize) and skip the next step.  
6. Run: `./configure`  
7. Run: `make`  
8. Run: `cp modules/xdebug.so`  
9. Update `/etc/php.ini` and change the line  
`zend_extension = xdebug.so`  
10. Restart the webserver

Giving me the next new problems 😕

1. ERROR The version xdebug-3.0.2.tgz is not published on there website.
2. ERROR Homebrew can’t install PHP on the latest version of Big Sur  
And basically these errors prevent me to complete the next steps ☹

Any suggestion to install a “local” PHP on the latest version of Big Sur? Any other package where I just can select PHP to be installed and configured in my User folder?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [January 7, 2021, 1:37pm UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/10 "2021-01-07T13:37:54Z")

</div>

> [@JeroenVunderink](#):
>
> @tflight I also looked at Bitnami to do this instead of with Homebrew, but can’t find a as simple install for PHP under my user with this package. I do not want to install any other packages, I just want to setup PHP, PECL PHPIZE and XDEBUG.

You can choose to install Bitnami apps/stacks under your user instead of the default /Applications if you wish, however you will get everything within the application/stack you pick. I don’t believe they have a standalone PHP installer except for [PHP-FPM](https://bitnami.com/stack/phpfpm). I don’t know if that comes with Xdebug.

I am using the latest Big Sur, and Bitnami does ask you for the install location when you run the installer, but yes aside from choosing the frameworks you want or don’t want, it will also install a version of Apache, MySQL, etc. This approach works great (for me) as I’ve got PHP 5.6, 7.0, 7.1, 7.2, 7.3, and 7.4 all available to me and can easily stitch between then. But I also use their Apache and MySQL, etc. I’ve used their installers for so long it has been many years since I’ve installed PHP any other way. But for sure, this approach may not be for you.

---

<div class="post-metadata">

**Author:** ![JeroenVunderink](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@JeroenVunderink](https://discourse.slimframework.com/u/JeroenVunderink)\
**Post date:** [January 8, 2021, 7:42am UTC](https://discourse.slimframework.com/t/debugging-a-slim-back-end-with-different-front-end/4594/11 "2021-01-08T07:42:00Z")

</div>

I found this website with in my view great instructions:

> **[macOS 11.0 Big Sur Apache Setup: Multiple PHP Versions](https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions)**
>
> My Grav Site

I absolutely see the advantage of setting up my mac differently with having Apache, PHP and XDEBUG configured under my usr folders. So changing now from standard to usr setup. The website expains clearly how to do it. Maybe it’s me but always like to understand what’s happening before installing via packages.

For other users: Even though when validating the versions the CLT (command line tools are already installed, use “Software Update” to install updates) showed that I was on the latest versions, brew still reported a warning and indeed after removing the CLT (sudo rm -rf /Library/Developer/CommandLineTools) and reinstalling them ( sudo xcode-select --install) I could install via brew.

Continuing my installation journey now first by installing Apache, PHP and XDEBUG and hope to be able to make XDEBUG work.
