Install M2 on Windows a bit easier

Daniel Fahlke
2 min readJul 16, 2017

--

Over the recent years the share of Windows systems for engeniers continuosly got less, and thx to Vagrant and Docker the focus on Unix and Linux environments increased even more.
But sometimes, having your PHP source locally running without any virtualization network magic, is still the best experience.
So I will try to show you, how to run the php part natively in windows.

requirements:
* PHP 7
* with intl-ext
* Composer
* MySql already availabel (on this machine, or another)

when this is prepared, get the source code via composer as you are used to.

Next, as we will use the cheap way without a webserver, you need to execute the setup:install via cli, not via web.

Cheap Way means, we use the php builtin server. You can find a Readme file in the phpserver/ subdirectory of Magento2.

After you started it and go to the url (with /index.php) you can already see, that it works.

Its beutifull, right?
Maybe we should also compile the CSS.
In my case, this did also not help, because the version part of the url is not resolving properly trough the router file we use for the php builtin webser. But thats not your problem, but mine.

I added this code into the router.php file, and it did solve the problem.

if (strpos($route, ‘static/version’) === 0) {
$redirectRoute = preg_replace(‘#static/version[0–9]*/#’,’static/’, $route, 1);
$debug(“redirect static version string to:” . $redirectRoute);
header(‘Location: /’.$redirectRoute);
exit;
}

And now it looks directly a lot better.

A PullRequest for this Issue got created here: https://github.com/magento/magento2/pull/10250

Conclusion

Magento2 itself is already quite easy to use on Windows, if you dont need a Webserver.

For MySql, Redis, ElasticSearch or whatever additional service you need is maybe still an Issue, but thats a whole other topic. And you could still use a vagrant or docker box to provide them. Or boot up a temporary server on the Internet like I did for my test.

--

--

Daniel Fahlke

#php #magento #composerphp and also a lot of annoying random #stuff - Likes to be the advocatus diaboli - also http://m.atchuup.com/how-to-understand-introver