Spring vs Laravel

Audrus
3 min readApr 7, 2018

--

Laravel is a great PHP framework, one of the best frameworks. Spring framework is developed for Java.

4 years I programmed with Laravel. It was easy to understand. Laravel has clean syntax, a clear documentation. Laravel’s components: Security, Blade Template, Eloquent ORM, Artisan console, File Storage, Events and etc. I like Laravel’s Security concept, because it is clean and easy to understand. Laravel has all components for beginners developers.

But I left Laravel, left PHP. I have been working with Spring since October, 2017. When I chose Spring, I thought: Spring is simillar to Laravel, it only writen in Java. But I was wrong.

Firstly Spring for me was understandable, but when I went deep to Spring I got confused. I started to read a documentation. The Spring documentation more complicated than Laravel. Yes, I know about Spring Boot, but I firstly want to learn Spring.

I installed Eclipse, created Mavean pom.xml file (like composer dependencies). When Spring downloaded to my first project folder, it not worked. Why? Laravel after installation always works. Spring doesn’t work without configuration. I searched in Google solutions. But is difficult for Spring to get solutions. A lot of solutions is outdated. I tested, searched solutions for two weeks (8 hours per day). And Spring started!

Spring families, or modules are very comprehensives. Spring’s modules:

Spring Core
Spring Security
Spring MVC
and etc.

What is Spring Security? Perhaps it simillar to Laravel Security? No! If Laravel Security is Lake, than Spring Security is Ocean. Spring Security has itself documentation, and it documentation bigger than all Laravel documentation.

Where Spring has route file? I know — Laravel has routes/web.php. But Spring works by other syntax. I forget one thing — PHP != Java. PHP is poor language. Java has annotations. And Spring uses these annotations for controllers.

When Java compiles your project, it gets all annotations and make application.

What about ORM? Laravel has Eloquent ORM. What ORM has Spring. I searched in documentation, but I couldn’t found. I felt stupid. Spring doesn’t has ORM.

For ORM I have to use others frameworks. Like Hibernate. Java EE has ORM standard specification named JPA. Hibernate is an implementation of an ORM framework. Hibernate documentation bigger than all Laravel documentation. It is other ocean. Hibernate has HQL syntax like SQL, but a few different.

SQL:
Select * from users;

HQL:
From users;

When I created entities (like Laravel models) with oneToMany, ManyToMany relationships I had to understand about Eager and Lazy loadings. I had to understand about List and Set collections. Because List collections with entities relationships work slowly than Set.

Template system. Laravel has Blade template component. What component has Spring. Spring has nothing. But Java EE has JSP template system (PHP has nothing). Better template system is a Thymeleaf. The Thymeleaf is other template system framework Java frameworks.

So. Spring was harder to understand than Laravel? Per six months I created first project with Spring/Hibernate/JSP/Java EE 1.8. This project works now ! Bussines client bought this system. But my knowledge about Spring/Java EE is very poor. I think, about Spring need to learn five times more than Laravel. If Laravel is car, Spring is spaceship.

But after Spring I don’t want come back to Laravel. Because Java is better for programming huge applications than PHP.

--

--