What PHP Developers Need to Know When Working With Sitefinity

by Gregg Crystal Dec 22, 2020

We meet a lot of PHP Developers who have been tasked with developing in Sitefinity. This can turn out to be a very daunting task, and this post will focus on what PHP developers can do to learn the platform quickly and effectively.

1. You Need to Learn .NET, but Not All of .NET

Sitefinity is built on .NET, SQL Server, and a variety of Microsoft Technologies. When we people say 'working with Sitefinity' they also mean 'working with .NET'.

An understanding of .NET is essential to Sitefinity development. But, like most modern languages, .NET is C-based and looks a lot like many other languages that you've seen, including PHP.

It doesn't take long to learn the proper syntax for functions, classes, for-loops, etc. .NET has other syntax that might help you, but depending on your circumstances, you don't have to learn all of it.

Start with a beginner course in .NET from PluralSight or Lynda. Don't forget, Stack Overflow is your friend here.

Note that if you are creating and styling a Sitefinity Template, than chances are you only need to focus on the .NET functionality that relates to MVC and Razor Pages.

Razor is the .NET syntax used within an HTML page. Sitefinity uses this in their MVC widgets within their Bootstrap Resource Package. You can easily look within Sitefinity's own files to see examples of how .NET syntax is used.

2. Being an Expert in HTML and CSS is a Big Plus with Sitefinity

The goal of any CMS is to output HTML and CSS to the browser. So you'll obviously want to leverage your HTML and CSS knowledge with Sitefinity.

To do that, don't get too caught up with 'Web Forms'. Web Forms was a .NET technology that was designed to obfuscate HTML. In theory it was supposed to make web programming easier. In reality, it made it a lot harder, and most .NET programmers shun Web Forms for the newer technology, MVC.

When I hear PHP developers complain most about Sitefinity, the struggle is usually with Web Forms. Web Forms is a bear, and the controls that you use to create forms, tables, and to use AJAX have a VERY steep learning curve. Nothing is overly intuitive.

If you're starting a new Sitefinity project, you can start with an MVC-pure install, using Sitefinity Feather controls and Bootstrap.

MVC has much simpler syntax, and you'll be surprised as to how much MVC User Interface code actually looks like PHP code.

By that, I also mean you'll be surprised at how much MVC UI code actually looks like HTML, which you're already familiar with.

Also note which version of Bootstrap is installed with Sitefinity. The latest version (13.x) used Bootstrap 4.0. 

3. Use Module Builder Extensively

One of the goals of Sitefinity is to seperate content from presentation. One of the easy ways to do this is with Module Buildler.

Module Builder is a very easy way to create content about 'things', such as Testimonials, Authors, and Locations.

For instance, you are able to (without writing any code) to create an 'Author' Module that keeps track of all of the Blog and News Authors on your site. 

Once created, Sitefinity has built of the administration screens that Content Managers can use to create, edit, and delete an Author. Sitefinity will also allow for translations of this content, and the content will be available in Site Sync.

Sitefinity will also create a couple of UI controls that will allow you to add Lists of Authors and Author Detail onto any page. You can also customize the look of these controls.

So get to know Module Builder! While there are some performance considerations with this Sitefinity feature, all in all, it's the perfect tool for creating UI components that have small data sets, like a testimonial widget.

A lot of the code is written for you.

4. Consider Using Angular or Some Other Wonderful Front End Javascript Library

Sitefinity 9.x and above supports the Web API out of the box, and auto generates API calls for your custom modules that you built with Module Builder.

What does this mean for you? It means you can create custom front end UI controls without knowing any .NET!

So if you already know Angular, using the Web API calls to get data from Sitefinity is a breeze.

5. If You Have to Read/Write to a Database, use the Entity Framework

The Entity framework is the best and quickest way to connect to your custom tables in a SQL Server database. So much of the grunt work of reading and writing data is handled for you by the framework, and you're only one PluralSight or Lynda course away from learning it.

Again, you don't have to become an expert in the Entity Framework to be productive. The basics will get you pretty far.

The Entity Framework supports building a Class in .NET first, and then the framework will actually create the database table for you. It's that simple.

6. What Do You Do If You're Stuck With Legacy Web Forms Controls?

If you're absolutely stuck with Web Forms controls that you must support, you could at least start new development with MVC and/or Angular. At the very least the pain of Web Forms can be contained with Legacy code.

Sitefinity supports Web Forms and MVC within the same project. Angular works with anything.

Of course, you have to get your Sitefinity version up to 7.x or so to take advantage of MVC.

7. Keep Sitefinity Up to Date!

One the biggest obstacles we see with Sitefinity Development is people using an old version of Sitefinity. Anything older than version 11 is probably too old to continue to maintain.

Progress does a great job of constantly upgrading and improving Sitefinity. Many of the issue that developers run into have already been fixed. Sometimes in a version of Sitefinity that was released years ago!

This is especially true when working with Module Builder, MVC, and Bootstrap. The early versions of these technologies were a lot less feature rich and had many issues. 

8. Develop in a Test Environment

Aside from creating content, there's no development that I would consider attempting in a production environment. 

I get many panicked phone calls from users that have done something to bring their entire website down (such as removing a key template file).

Do all coding and development on a test server or even locally on your PC.

 

 

 Take Control of Sitefinity