New to electron, beginner questions



I’m very new to electron and js as a whole, been more of a laravel/php person, but I’m wanting to get into desktop app development and think electron would be the best way. I’ve looked at some tutorials about it but I’ve still got a few questions.

  1. What is the standard structure for an electron app?
  2. How can I make my own css files and compile them like you can do on laravel?
  3. What is the best way to store large quantities of user specific data?

Thanks for the help


The Electron documentation covers that. In short, you have one script that the Electron executable runs as a Node script and calls the “main process” (think of this as the browser application before you’ve opened any windows) that controls all of the windows you want to open. Each window is a “renderer process” and functions very similarly to a Chrome tab.

How can I make my own css files and compile them like you can do on laravel?

You may need to be more detailed, since not everyone here has used Laravel. In Electron, you style your code the same way you do in HTML. If you want to compile Less or Sass to CSS, you can incorporate that into the build process of your application or just do it live whenever one of your files updates (you have Node available, so you can easily use packages from NPM to compile CSS).

What is the best way to store large quantities of user specific data?

It will depend heavily on your needs and use case. You can install any database you want (especially the ones with a package on NPM) or you could write to a folder on the user’s computer or make calls to a cloud service. Most storage solutions these days are designed to handle large amounts of data. If you want to make the data specific to a user account, you can put your storage in the user’s home folder.


I also have some limited experience developing in Laravel before coming across Atom. Atom/Electron veterans will argue that PHP and Electron do not mix well (multiple scopes). But search around and you will find this …

For my own development purposes I am exploring using hybrid PHP in a custom package.

So I would argue, leverage your gained knowledge of Laravel and regard Electron app as the wrapper as one option. There are several Atom packages for database connect. Look at Mongodb for example.


You have to have a special setup so that you can actually parse the PHP files into HTML which the browser can read, and then instead of writing in one programming language, you’re forced to write in two, and if you want to do any IPC-related activities you will need to have your PHP code dynamically render some JavaScript. Having designed Wordpress plugins professionally, I know that PHP developers are no strangers to that sort of hacky rendering of other code languages (including JS), but I wouldn’t try to do that today.

It does not sound like fun to me to code in the setup you describe.


This is the claim which attracted me to explore Atom …

A hackable text editor for the 21st Century

And I admit that mixing grammars (PHP, JS etc) may be a hack too far.
But I can achieve permutations which I would personally find difficult to learn using JS only.

I am using Atom package php-server which allows me to write dynamic JSON in PHP. In fact all that is needed is to import existing JSON files in Atom. No fiddling with Atom Settings … and then Window:Reload to refresh. I can switch settings on the fly using PHP variables. I have adapted one autocomplete+ provider to switch to the snippets library I prefer.

Here is one of many blogs in my bookmarks explaining how to apply this hack.

To read JSON as a URL (i.e. serving a PHP file) one has to only define a PHP header for each file type …


header('Content-Type: application/json');


I’m not sure what you’re getting at by talking about how hackable Atom is. This thread is about writing an Electron application, and @hcphoon01 has made no mention of using Atom as an editor.

Every modern code language has a library to read JSON, because JSON is the language spoken by REST APIs. Even string-banging to assemble JSON the way you do SQL calls in vanilla PHP is a much lower order of difficulty than using the same process to build actual JavaScript code to be executed.