Please note that the forum isn't realy used anymore.

If you have questions, want support or just simply want to talk to us you can find us on slack.

 

Local setup problems

Hi,

I've just recently started developing with php, (I'm more used to node.js or java) so perhaps some of these questions will be a bit basic. I'm trying to figure forkCms out, maybe make some modules, and learn advanced php along the way. However, I've ran into some troubles with my basic setup.

First of all, what would you guys recommend to run forkcms locally? I've already tried with vagrant, though after 2 days of error hunting I've returned to XAMPP. I can get it to run on my localhost, yet I've encountered the following issues:

I cannot install a module. Whenever I try to upload a zip file through the settings menu, I simply get a "something went wrong". (It also says: We could not find a module in the uploaded file. Verify the contents.) Now, I've also tried to install forkcms on my webspace (at nucleus), and I can install modules there with no issues. What could be the problem here?

A second issue I've ran into (only locally) is with the css files. None of the stylesheets were found, and I had to copy the Themes folder from Frontend and the Core folder from Backend to get them to work. Apparently, fork tried to find the stylesheets for the backend in, for example, src/Core/Layout/Css/imports/autocomplete.css instead of src/Backend/Core/Layout/Css/imports/autocomplete.css.

So basically, my question is this: What would you recommend as a stable development environment for a beginner, and why do I run into so many problems while simply trying to run fork in XAMPP?

Thanks!

I always worked with MAMP Pro. If you're working on OS X I would recommend that, otherwise XAMPP or WAMP should be fine either. There's a Windows version available too, it's in alpha, but it should be good too. But I recently switched to a Vagrant setup. In MAMP, I always created a new host (for example, "websitename.localhost") on the hosts tab, created a new database in mysql (Sequel pro is a good app on mac to manage mysql), visited my website and installed Fork CMS and that's it.

It's best to work with debug mode enabled. You can do this by adding an "environment variable" to your virtualhosts file (or in MAMP you can add the parameter to your hostname: http://cl.ly/image/1S193I341h3A). If this method doesn't work or you don't like editing the virtualhosts file, then you can always try the htaccess method or just edit index.php in the root of your website and add putenv('FORK_DEBUG=1'); on top right after the <?php line of code. Debug mode will disable caching, allow you to see detailed error messages instead of "something went wrong", and add "noindex, nofollow" to your meta so your website will not get indexed into Google. So if you upload your website to a live webserver, make sure there's no debug mode enabled or it won't show up in google ;-) But when you develop and make changes to php code or templates or css, then you should definitely use debug mode. When I just started using Fork CMS, I made some changes to the templates and CSS but it could take a lot of time before I saw those changes (due to caching). You can check if debug is enabled right above your login form when you visit the backend, or in the right corner of the backend like it is here: http://cl.ly/image/0O1H3N0q2O1V

Maybe with debug enabled, you'll get a clear description of the error when you install a module... But I have to say that I never use the install-module-with-zip functionality. I always simply copy the src/Backend/Modules/Modulename folder and src/Frontend/Modules/Modulename folder to their appropriate place in Fork CMS. If you visit the Backend > Settings > Modules page, then the module will appear in the "not-installed modules" section. The module will install just fine normally.

I never heard about that problem with the CSS. Could be a problem in the latest version of fork cms because i havent tried it out yet, but I will tomorrow and check it out. Could be XAMPP too that causes the problem. But if this keeps happening, maybe you can create an issue for the developers.

Most of the modules of Fork CMS don't use advanced php. It's fairly easy once you get the hang of it. In the model.php you have some functions that can create/read/update/delete things from the database. Then you have some action php code for every "page", and they use a template file with the same name. Those actions just do something with the data and parse the variables or arrays into the template. Oh and you have Modules or widgets. You can insert a module on a page and you can visit url's based on this module page (if you add the Blog module on a page named blog, then you get: /blog, /blog/archive, /blog/detail/this-is-my-blogpost-name, ...). A widget is something smaller. You can insert a widget on a lot of pages. Examples are a tiny block that shows the top 5 recent blogposts, the recent comments, the tags, a list of blog categories, ...). The documentation can be helpful, the cheatsheet too. But I learned to create a theme just by figuring out how the Triton theme works. Same goes for the modules. I checked out the code of some modules like Blog, FAQ, etc and I learned a lot.

If you want to make your own module, a great way to start is the Modulemaker module. Install this into Fork CMS and go to the modulemaker module. Follow the steps of the wizard to create the basics of your module. At the end, you can download/install your generated module. Most of the time, I use this to create a very primitive version of my module and then I keep changing and adding code until the module is completed. The modulemaker creates the action files and templates and installer and all other files that you will need, and it generates a lot of code that you don't have to waste time on to write yourself :-)

If you have other questions while trying out Fork CMS, let me know and I'll be happy to answer them.

Thanks for the response guys! I'll definitely try these as soon as I'm able.

Comment

The forum is deprecated in favor of our Slack channel, which provides real-time support for your issues.

Join us on Slack here: https://fork-cms.herokuapp.com/