August 11, 2016Yann Jacquot6 min read
Step 1: Create the Native iOS code in Objective C. Open the React Native project in XCode as one should not create.h and.m files within PhpStorm of VisualStudio Code or whatever their preferred editor is. Creating these files should occur in XCode. I work on React-Native in WebStorm. I have some class, I want use auto import function of WebStorm, It works for some classes, but not for all. When I type name and hit Ctrl + Space, it does not auto import class. I tried Alt + Enter also, it has no import suggestion in list.
Warning: this article concerns php5 version. If your PHP version is different, replace php5 by php/X.Y in paths (X.Y is your PHP version) and phpX.Y in command. For example :
![Phpstorm Phpstorm](https://i.stack.imgur.com/kVfeL.png)
sudo apt-get install php5-xdebug
becomessudo apt-get install php5.6-xdebug
/etc/php5/mods-available/xdebug.ini
becomes/etc/php/5.6/mods-available/xdebug.ini
Running your React Native application Install the Expo client app on your iOS or Android phone and connect to the same wireless network as your computer. On Android, use the Expo app to scan the QR code from your terminal to open your project. On iOS, use the built-in QR code scanner of the Camera app. React Native Console an IDEA/WebStorm/Android Studio Plugin for run React Native commands and coding easier Notice. React-native, react and native-base version RN: 0.45.1 React: 16.0.0-alpha.12 NativeBase: 2.2.0 Expected behaviour Since NativeBase has its type definitions file.
I love debuggers. They allow me to understand deep down in my code why something doesn't work, and are even more useful when I work on legacy projects.
When I work on the client side, the browser already provides me all the tools I need to dig deeper than some console.log()
scattered semi-randomly in the source code.
However, I struggled to configure my workspace when I worked on a PHP Symfony2 project hosted in a Vagrant virtual machine.
Step1: Install Xdebug on your Vagrant virtual machine
That may seem obvious, but you need to have Xdebug installed on your virtual machine to benefit from its services.
Then, configure it:
with the following lines:
Finally, if you use php5-fpm, you need to restart it:
Phpstorm React Native Tutorial
If you use Ansible to provision your virtual machine, you can also use a ready-to-action Xdebug role.
Step2: Configure PhpStorm
First, select the 'Edit configurations' item in the 'Run' menu.
Then, add a new 'PHP Remote Debug' configuration.
We will use the IDE key configured in your Vagrant and in your browser.
To fully configure this debugger configuration, you will need to create what PhpStorm calls a server.
- Fill the correct hostname
- Check 'Use path mappings' checkbox, and write the project's absolute path
on your Vagrant virtual machine
Step3: Configure Xdebug
Use Xdebug to debug your web application on Chrome
Now that Vagrant with Xdebug is up and running, let's configure Xdebug Chrome extension.
First, we need to install it from Chrome Web Store
Make sure that the extension is enabled on your browser's extensions list page.
Now, you should see on the right side of the address bar the extension's symbol.
Right-click on it, then click on the 'Options' sub-menu.
You have to use the IDE key previously set.
Xdebug plugin also exists for other browsers.
Finally, in your browser click on the bug in your address bar to switch to the 'Debug' mode
Use Xdebug to debug your APIs route with Postman
Once your Xdebug configuration is added, you need to add ?XDEBUG_SESSION_START=_<XDEBUG_KEYNAME>_
at the end of your route. And that's all!
![Phpstorm React Native Phpstorm React Native](https://resources.jetbrains.com/help/img/idea/2021.1/ws_react_rename_component_from_another_file_light.png)
Use Xdebug to debug commands or unit tests
To use Xdebug for debugging commands or unit tests, first, you need to add xdebug.remote_autostart=true
in XDebug configuration file of your Vagrant xdebug.ini.
Then, you need to specify the xdebug.remote_host
(IP address of your local from your Vagrant) when launching the command from the virtual machine’s terminal.
- First, get the host IP address by using
ifconfig
from your local terminal (the host) :
- Then, launch your command
For instance, if you want to debug your unit tests in a Symfony project, you can run:
Step4: Enjoy!
Now, in PhpStorm you:
- Add your breakpoints by clicking to the left of the lines
- Click on the bug icon on the upper-right corner
You should now be able to break on the exact line you selected in your IDE.
Bonus: Performance
![Phpstorm react native free Phpstorm react native free](https://blog.jetbrains.com/wp-content/uploads/2017/01/webstorm-cra-debug.png)
You need to know that enabling Xdebug slows down your app (x2), the fastest way to disable it is to run the following command: php5dismod xdebug
Use php5enmod xdebug
to enable it back. Each time you'll also need to restart php-fpm or apache.
Troubleshooting: I did the tutorial but Xdebug doesn’t work
It’s probably because a symbolic link is missing in your php conf.
- First type in your virtual machine
php -i | grep xdebug
If you have no response, it means Xdebug is not set correctly
- Then check if Xdebug is mentioned when running
php -v
from your Vagrant. - If not, add a symbolic link to specify that the Xdebug module should be enabled, for instance (you may need sudo):
- You should obtain by running
php -v
I hope you've made your way through the process and that it will improve your efficiency as much as it does for me. If you have other ways to configure your debugger, feel free to share them in the comments section below.
Some of you might think “why would I need to open AVD inside Webstorm?”, and maybe even be correct, as the newest versions of Android Studio working on the Intellij Engine as well(and also doing it pretty well).
But, the programmers that are working with WebStorm or PhpStorm on the daily, they wouldn’t want to move to Android Studio every time they decide to work on a React Native project.
Phpstorm React Native App
As one of those “programmers”, I have found a simple workaround that works for me. Follow this steps, and you will be able to use Android AVD within WebStorm in no-time.
- Open a new React Native project in WebStorm or PhpStorm.
- After the new React Native project has been created, open that same project with the Android Studio IDE
- Run the Android AVD as you usually would
- Close Android Studio
- Go back to WebStorm or PhpStorm and run(with the react native cli) the usual command, “react-native run-android” and that would open the app inside of the Android AVD(if you see an error, refresh the Android AVD using the usual double-click on R.
That’s it, and now you can enjoy working inside PhpStorm or WebStorm while running the comfortable Android AVD emulator.
Phpstorm React Native Theme
BTW, from the screenshots, you might see that I am following The Complete React Native and Redux Course by Stephen Grider, if you are interested in learning React Native, I highly recommend checking out his course on Udemy.
![](https://cdn-ak.f.st-hatena.com/images/fotolife/r/ruriatunifoefec/20200910/20200910011346.png)