I'm a little confused about how exactly I should approach using Laravel. Right now I have a React application that runs through NPM. This then calls restful PHP API's. So more or less my backend and frontend are separate.
In Laravel, it seems that you develop your frontend within Laravel itself (reminding me of applications like WordPress) with it's MVC architecture and routing capabilities.
Should Laravel be used just for API development? Should I be looking to integrate my app (based on create-react-app) into laravel itself? Am I thinking about all this completely incorrectly?
Again forgive what I'm sure is such a newbie question and any resources you could point me to in helping me understand the framework would be great.
An independent UI communicating with an API would be a SPA, Single Page App. And depending on the size or complexity of your application, that's a completely valid way to go. Especially if you can conceive of a non-browser platform like a mobile app communicating with your API at some point down the road.
Laravel Blade Views are entirely optional. They're a really nice templating engine, and not necessarily incompatible with React at the same time either. But if you're more comfortable managing your UI in a separate codebase, the short answer is, it all depends, so do what you're comfortable with.
Related
First of all I hope I'm allowed to ask such a broad question (first time doing so).
Ok so I'm very new to React & I need a project to work on so I thought I'd recreate my portfolio (currently created in laravel) as a react & react native app.
My questions are:
Would a Rest Api NETCORE backend be a good choice for react ?
My experience is more in ASPNET MVC than Core, should i just stick
with MVC API's for now (i've already started creating a NETCORE Api
for learning purposes)?
Would a php framework such as CodeIgniter be better for this kind of
job?
My main question is if this is a good approach? I'd like to have a basic backend (auth, news posts, portfolio items etc) and then continue building on my react apps.
I was thinking that by creating a Rest API backend it would save me a lot of trouble when trying to create a react app for PC,Android or whatever (same back-end, different client).
P.S: i'm going to host my API on Azure's free websites if its ASPNET or a shared hosting if its PHP, that is the reason for which im moving away from laravel (so laravel is a no-no).
P.S2: Firebase or other clouds (except Azure) are a no-go for me. I have access to lots of resources and i'd like to use them & not use free services like firebase or whatnot.
Just giving my 2 pence here, as this is really opinion based!
In terms of the backend, it's up to you, whatever you feel more comfortable with - but I would give a keen eye on the architecture of the backend system you build.
My choice would be to create a micro services based architecture where you create simple, atomic services which only deal within their domain. For example, you could create 'Common Services' - services which can be used as dependancies by other services (events, encryption, documents etc..) then create atomic services which deal with an aspect of your application such as User Service, Payment Service, Product Service, Basket Service etc..
The idea is simple, to create simple data driven CRUD services which are modular, atomic and reusable. I've found that learning new technology is great but understanding and learning good programming architecture is even more rewarding. You can structure data to make it the most efficient for you.
Once you have built a service, you could use services like Swagger UI to automate documentation and create testing suites for them. If you haven't used Swagger I throughly recommend it.
Implement testing for each service, and go through the whole lifecycle of software development. That will really go far in your portfolio.
Here are some articles relating to building microservices in ASP.NET Core
https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/data-driven-crud-microservice
Swagger
https://swagger.io/
As a side note, I do not develop in ASP nor any other microsoft stack - but the principle is the same
UPDATE
The issue with building monolithic applications is that the code base can get more and more complicated and huge as your app grows. Some advantages of Micorservices are:
Scalability
Fault Insolation
Eliminates long-term commitment to a single technology stack
Easier for developers to understand (and document)
My type of set up would be using Spring Boot (Java) and using Eureka Server - but you are into the MS Stack, but the link I've given you above shows how to create a basic CRUD microservice with Net Core. I would give that a go, and see how it goes, then you can move to CI/CD for Azure!
Moving on from just a simple CRUD API, you can introduce WS connections with event driven updates (server to client) rather than asking for new data.
An Architect that I once worked with (a genius guy) told me never to be too reliant on a 'Framework' - they're cool when they are doing well, but a great application should be flexible to change, so I wouldn't rely too much upon a 'framework' but that was just his opinion.
Try API Platform - dockerized, but deployable to php hosting (based on Symfony), generates react-admin based admin and optional web/mobile clients (IMHO the weakest parts of this project), openAPI (swagger) docs, easily usable with graphQL ... just try.
Building portfolio with Laravel isn't a good idea. Use Gatsby - you can use graphql (WordPress, contentfull) as a source, generate static site.
I am working on a ERP system that is 6 years old and it is developed in raw PHP maintaining procedural coding structure without OOP or any Framework.
Finally our management decided to re-write the application with upgraded technologies. We will write the application in Laravel Framework. Database will be Oracle and Mysql both. In the front end we will use Angular 4.
The confusion is should i use Angular 4 for front end request handling and data binding? Or i should go with Javascript/Jquery. Last few days i am seeking some suggestions on the net. I found some also. My question is, how should i integrate Laravel and angular? should i go for API based approach maintaining two different project for Laravel and Angular or angular inside Laravel in a folder? If i go for API based approach, will my ajax request increased? The database of the application will be too large.
will API based approach make data loading slower?
All the request in the application will be ajax based and there will be no page refresh approach, but url will change on request.
Please suggest me the possible right solution to help me taking the right decision.
Angular 2/4+ has been designed to build SPA (Single Page Application). If you deep dive into angular then it will be clear to you that all the structures and conventions followed in the angular 2+ architecture are optimized for SPA.
So, if you want to use Angular with Laravel 5+ then I think the best way would be to use angular to build a standalone frontend application and use Laravel 5+ as a backend. That means laravel will act as an API server and a backend of the application.
Using laravel as an API server doesn't necessarily mean your database will be bigger. It is actually upto you how you design your application.
But, there is an another good solution.
You can use VueJs. There is a build in support for VueJs within Laravel 5+.
The benefit of using VueJs is that you can use it just like Jquery. That means you don't have to create separate standalone application for VueJs like Angular.
But, you can use it, page by page basis. It is loosely coupled.
You will get most of the benefit of Angular from it.
You can also use React.
You can use Angular 4 to rewrite your application. Fontend as Single Page Application and Backend exposing REST API will help you to build a good performance application.
I prefer to keep Angular and REST API separate as they should be independent to each other. REST APIs should always be generic so that they can be consumed by other applications too.
Yes, there will be lot of API calls to server. You can scale your REST APIs according to your number of requests. It is better building micro-services to ensure most of the services will not be impacted in case of lot of heavy load (at least part of application will be running). It will help you in future maintenance also.
I have experience with Joomla and have modified and wrote some simple Joomla extensions. I don't have experience using one of the popular PHP frameworks (such as CakePHP), but I was thinking about using the Joomla framework because I'm familiar with Joomla. How would I use the Joomla framework for a software project instead of using regular Joomla and writing the extensions needed for it to extend it's capabilities? Thanks!
The basic idea is that you:
Get a copy of either the whole framework or just the packages you need+dependencies (from github or composer) or use the older copy that is shipped with the CMS,
Bootstrap your application (JApplicationWeb or JApplicationCli).
Write your code using the MVC structure provided.
The big difference with writing a totally independent application is that you are doing just that, you need to build everything in the application whereas in the CMS there are already a lot of things in place. (The good part of that is that you can make new code with no legacy concerns.) For example, if you look at the JIssues project you'll see that they had to think about things like authentication. So as you would expect writing a simple application is simple, writing a complex one is complex.
You can see many examples of framework applications around, ranging from the ones found in the CLI folder of your CMS installation to JIssues, and of course the three web applications in the CMS are all examples of applications on the framework.
The Joomla Framework is intended (among other things) to be the platform upon which you can build a web-application. The framework is like the frame of one of those motorcycles they build on "American Choppers." It provides the backdrop so that you can hit the ground thinking about your app without worrying about User Authentication, database connection, and a thousand other things like those that get in the way of bringing your app to its potential audience.
If you're trying to extend Joomla, the current edition is what you should be using.
I have been tasked with building a simple web based system for managing a list of vehicles.
I am interested to know whether there are any robust, clean PHP 5 frameworks / libraries that are specialized in doing this quickly.
They should be able to quickly build a skeleton web back-end to an arbitrary data structure with the basic functions:
Customizable list view
Customizable edit form
create/update/delete operations
Nice to haves:
Multi-user interface
ACL based rights system
Localization
Image / File upload built in
Wet dreams:
A skeleton CRUD API to manage items programmatically
A skeleton RSS feed to inform about new items
I am aware most big frameworks provide tools and helpers for this, but would prefer a standalone, light-weight solution that is easy to get into.
Alternatively, is there a great PHP application that you would recommend looking into to modify to suit my needs?
As far as building skeleton apps goes, nothing comes close to the Yii framework.
From the site:
MVC, DAO/ActiveRecord, I18N/L10N,
caching, jQuery-based AJAX support,
authentication and role-based access
control, scaffolding, input
validation, widgets, events, theming,
Web services, and so on. Written in
strict OOP, Yii is easy to use and is
extremely flexible and extensible.
It also includes CRUD code generation. Headed by the guy who did Prado.
If you don't want a big framework, you could check out phpactiverecord
I would recommend CakePHP
I've seen awesome demos of the instant blog in Rails and Django and Symfony.
Looking at Zend, Cake, Symfony, Symfony seems the most like Rails/Django. Check out the 10 minute (yeah, super sped up!) demo. It's pretty sweet:
http://www.symfony-project.org/screencast/cart
My experience tells me that there's no framework, lightweight or otherwise that you can easily do what you want quickly if you don't know it. So that's where the tutorials come in. You really need a nice ORM to avoid all that mess with the DB and or reinventing that with a CMS. So the best bet is to choose the one with the best docs, the best tutorial + screencast, in the language you know that gets you closest to your requirements by just changing the names of the variables. I know Django can do all that you're asking with Django 1.2, but with PHP 5 being the requirement, Symfony and it's ORM is my first suggestion.
Yii looks like something I'll be taking a look at right now! Yii-Haaw!
Here's Yii's screencast of blog making: http://www.yiiframework.com/screencast/blog/
Not bad so far! But it's quite a learning curve to get the blog working. Very similar to Rails.
The best i have seen around in years http://www.grocerycrud.com/ its for codeigniter
Sapphire has a lot of promise. I have used the CMS built on it - SilverStripe - for a few projects and it's very nice. But I haven't dug into the back-end too much.
From the website:
Our Object-Relational Mapper takes
care of your data. Define your data
model using our simple PHP5 syntax
and our ORM does the rest.
Tell
Sapphire about your data model, and
you get 3 interfaces for free. A
RESTful API, a SOAP API, and an admin
editing interface.
It's not exactly lightweight, but its core is ~1.3 MB but meets a lot of your "nice to haves"
There are several PHP frameworks that meet your requirements (basic requirements). You should use a framework that you are most familiar. If you do not familiar with any framework, I suggest you to use the CodeIgniter.
I've been looking for a drop-in admin panel like this too, so far I've 2:
AjaxCrud - http://ajaxcrud.com/
Peek from Code Canyon - http://bit.ly/toKKrB
Love to hear any other suggestions!
We currently use MySource Matrix CMS for large projects, Wordpress CMS for small projects and Zend Framework for bespoke applications...
I'm not trying to confuse and compare a CMS to a framework, that has been done before :-)
I want to identify a few CMSs for review that have foundations in strong (preferably independent) PHP frameworks.
The only one I have looked at is SilverStripe CMS and Sapphire Framework.
We have many clients that have a CMS for internet and/ or extranet and then various other bespoke applications that are then integrated via various means to look like they're in the CMS.
I believe it will be more productive and beneficial to have a common framework between these branches so they can be natively merged.
Hope this makes sense.
PS. I have used custom assets in MySource Matrix and specific modules in other CMS but you feel you are working for the CMS not the application you are building.
Have you looked at Expression Engine? Its built on top of the CodeIgniter MVC framework, and may provide a lot of flexibility for having parts of the site be managed content, and branching out into more application type stuff using CI when needed. Not free, but all my colleagues that use it, swear by it (so much so that I'll actually consider it for the next project that fits this profile). There are also add-ons for many of the commons problems you're likely to want to solve.
And while not PHP, the Django framework is also a nice cross between CMS and App Framework, with some really great features like DB Migrations, etc. I can honestly say that Learning Python made me a better PHP Programmer, and the projects I've done with django were fun and fast to code. Not to start a holy war, but I describe Django as Drupal without all the clutter (and yes I've worked with Drupal enough to respect and fear it at the same time ~ too much friction in the Drupal dev process for my taste).
Even if I didn't get clearly what you are looking for I was just searching for a CMS that is not bundled with a propietary PHP framework and it should also be fast, simple coded, ordered and flexible to extend.
After a lot of search I found OctoberCMS. It uses Laravel PHP framework and it's intended for wevdevelopers/programmers, may be in a future it will also support more WYSIWYG edition. Right now it's very fast and easy to extend via MVC implementations or plugins.
It has a nice code and structure to work as programmer. If you like to create content via HTML+CSS and you don't care about WYSIWYG, then this could be a great alternative.
It's a very different approach compared to other CMS bundles. I'm not saying it's better, just different.
With their slogans:
The PHP framework for web artisans
http://laravel.com
The platform that gets back to basics
https://octobercms.com
Have you tried Drupal? We have used it as a CMS and also integrated it with things like Microsoft Dynamics and UPS Worldship. It's pretty flexible like that.
I wouldn't call sapphire and independent framework for the simple fact you'll have a hard time finding many apps written in sapphire alone - sapphire pretty much is silverstripe. Theres also the issues of silverstripe using an ajax powered admin interface for much of its own functionality meaning you have to adhere to these to keep the same look and feel with the bespoke work you want to add.