📜 ⬆️ ⬇️

Debugging iframe applications directly in the vk.com environment using php + xdebug


In this article, you will learn how to debug an iframe application directly inside the vk.com environment, that is, as a white person. Developing an application directly in the environment does not require creating sandboxes (VKontakte emulation), it is very convenient to work directly with the VKontakte API, seeing all the variables that are passed back and forth directly in the trace. I do not pretend to originality, I just checked that there is no such article in all, and the idea is obvious and simple. He came up with an idea for a cup of tea, because if I could finish it, I would google it.


Anger


It causes a storm of indignation when I can not normally develop software. In PHP, the most hated is var_dump for me, which I use print_r in an emergency situation, that is, when it will be faster to debug it than to configure the full IDE stack to work, that is, less than half an hour, if from scratch - starting with setting up the Apaches . In all other cases, if there is no normal stack, it freezes me and I want to improve this situation in every possible way.

Problem


There is an iframe app inside vk.com. It constantly interacts with the user, API vkontakte and other things, like voices, using different secret keys and without them. Naturally all this is pretty damn hard to debug. From which it follows that applications starting from a certain level will cost an extremely large amount of programmer hours. In such situations, partially correct the situation sandbox. If you take into consideration Iframe, then if you slightly spread your brains over the sandbox in any of its variations, it loses its relevance due to complexity and not universality, because the application can be stupidly messed onto the development server, and there sits a programmer with IDE and xdebug.
')

Development stack


XAMPP 1.7.4, PHP 5.3, NetBeans 7.01, vk.com (iframe), xdebug, DNS

Stack Setup


I apologize for the rather poor textual information. I prepared a video that would be understandable.

- Configure apache
Go to virtual-host
<VirtualHost *:84> DocumentRoot D:\work\other\htdocs\ru-wartur-app\www\public-html ServerName app.wartur.ru ErrorLog D:\work\other\htdocs\ru-wartur-app\log\apache2\error.log CustomLog D:\work\other\htdocs\ru-wartur-app\log\apache2\access.log common <Directory D:\work\other\htdocs\ru-wartur-app\www\public-html> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 

Restarting our local development server, in my case XAMPP (I advise everyone).
Do not hesitate about the 84th port. I think if there are a lot of developers in the company, then they can get there to the 90th, but at me they are really all clogged at home.

- dns settings
Create a record A. In my case, app.wartur.ru is 188.134.79.140, that is, a mapping to a router.

- vkontakte settings
Come Vkontakt-> Settings-> Address IFrame : app.wartur.ru : 84 /

- Creating a NetBeans project
We will assume that you have configured xdebug, we will not dwell on this.
Project Settings -> Run Configuration -> Project URL: in my case app.wartur.ru : 84 /

- We start and enjoy life
- Put a breakpoint and start debugging inside the IDE, now we have a session in our browser and the IDE is set to debug mode
- Run the application, in my case vk.com/app2820627 , we see a profit from clicking on each new link, launching the API, or whatever else you want.

Video


I apologize for the quality, as always there is no time to redo, do not judge strictly


I hope helped. Good luck everyone. I like it very much when an article is filed in one hour and not stretched for 3-4 hours.

UPD: All that is written above is quite difficult. Everything is much easier if you do not need to simultaneously allow access from outside to your working machine.
- Remove from the DNS configuration scheme and everything connected with it.
- We put some localhost in the application settings, in my case app.warturru (I didn’t like this port 84 myself, so it was removed by hurray !!!)
Pasib Habra for tips! Good luck to all!

Source: https://habr.com/ru/post/138771/


All Articles