I'm supporting a legacy ZF1 application which now needs to expose a RESTful API to the outside world. I'd like to take advantage of a modern PHP package for some of the API's boilerplate functionality (authentication, request parsing, response generation in multiple data formats, etc.) rather than coding it all from scratch, or using ZF1's poorly-documented REST library.
Packagist suggests that FOSRestBundle is the most popular PHP component for developing RESTful API servers. And as far as I understand it, Symfony2 components are flexible enough to be used outside the context of a full Symfony2 framework-based application.
Has anyone has successfully used this particular package outside of a full Symfony2 project? If so, was it painless or were there some significant challenges that you had to overcome? I can see URL routing, and my lack of general Symfony2 knowledge, as potential pain points.
Any advice or suggestions would be greatly appreciated. Thanks!
I'm afraid you can't do it without hacking a lot.
I would recommend you to go for APIgility, there are some tutorials where you can the integration with ZF1. You'll also get the advantages of content negotiation, auth, documentation.
Related
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.
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.
For an existing PHP application, that doesn't make use of any frameworks... is it possible to add/integrate Laravel based authentication to it without trying to convert the entire PHP into a Laravel application?
I am a complete PHP newbie, and was hoping for someone to point me in the right direction. Much appreciated.
Of course you can add JWT to your existing PHP app, it's not "locked" to Laravel, far from it. Most of the frameworks that have these capabilities built in are just supersets of various components to make life easier for developers. You can of course implement these on your own in your application, given that you have the knowledge how to do so.
Since this is a bit abstract question without any provided examples, some answers with code snippets might just confuse you. Instead here are some resources where you can read more on the subject and get going: Sitepoint, JWT in PHP App and PHPClicks Token Based Authentication.
Another approach would be to craft a new Laravel project (or Lumen project if it's only a API and you don't want to render views) and import the current codebase from the other application to it.
If you want to make life easier for you, you can use some SAAS alternative for Authentication like Auth0.
I have never used a PHP framework before and am considering using Symfony for my next one. However, I have already built an API which has all my main classes. I will therefore connect to this API using CURL. Can anyone advise on where to start with such a project. I am working through a Symfony tutorial but none of it seems to apply to what I need to do as I do not need to create database connections or classes as I will be building this project on my existing API.
If you don't need a lot of what you see in the Symfony tutorials you might be able to get away with Silex. Silex is a mini-framework with alot of the core aspects of Symfony, but without the extra stuff.
http://silex.sensiolabs.org/
For the past time I have been working on a Zend Framework based webshop application that we are building from scratch. The application has been successfully been set up for several clients, but we are stumbling upon more and more problems regarding extensibility and modularity of the application.
A lot of clients require a lot of different approaches on some matters, often requiring customizing default modules or extending them. I have been looking on the web for Zend Framework based code that could guide me to this and so far Magento has been the only example I have come up with. Although Magento seems to do a very good job offering extensibility and modularity, the code is far too complex and extensive for my current needs (or so it seems).
In an ideal situation, it would work as follows:
Each client gets the "base" application installed
Modules, controllers, models should be easily overridden or extended
New modules should be easily created
Are there any other Zend Framework based applications or other pointers that could guide me in the right direction?
Thanks in advance.
I think version 1.8 of the Zend Framework is going to address a lot of the issues with building modular applications. Especially with the new (Zend_Application) it should allow for auto loading of module resources, which isn't easy to do at this point.
I don't know much about it, but this may be something to look into. 1.8 should be out by the end of this month.
Zend Framework is a... framework. What you're looking for is a full blown system. That's your job as a developer is to build a system on top of a framework (whether Zend or your own).
People usually tell you not to reinvent the wheel, but in this case you need to develop your own system for your company to easily be able to develop and deploy for new clients.
Like already stated, it is a very complex answer you are looking for. You will not get that answer.