API-Centric app in Laravel 5.3 - php

I want to make API (Laravel) and SPA (Vue.js) that uses this API. But I am not sure how to accomplish that.
2 separate projects (1 Laravel project for API and 1 Vue.js project for SPA)
or
1 Laravel project for both API (routes/api.php) and SPA (routes/web.php)
Which one to choose?

Separated projects are more clean and organized while all in one project is more practical.
What I do is create two different repositories ((project-api or project-server or project-backend) and (project-client or project-frontend)) if is a medium-large project and work on them completely separated. Both projects don't know nothing about each other.
Obs: The routing system on frontend is not managed by Laravel as appeared in what you wrote here and SPA (routes/web.php).

If you want to use separate projects, I suggest you use Vue-CLI for scaffolding Vue.js projects and Vue-Resource for web requests (XmlHttpRequest or JSONP)
Laravel also provides Laravel Elixir that support CSS and Javascript using Gulp and Webpack.
First, You must install node.js and npm, from there on I would suggest that you read the documentation to get you going further.

Related

App development setup with PHP and Vue.js

I am new to Nextcloud app development and would like to create a simple app to play around. I saw that some apps are made with Vue.js, so I’m asking if there is a guide out there?
I generated an app skeleton and played around with the PHP templates but unfortunately I don’t know PHP and would like to create a Vue.js project into this existing demo app.
I found some premade Vue components for Nextcloud
https://github.com/nextcloud/nextcloud-vue
but no step by step guide on how to setup the Vue project after creating the skeleton app. I just saw that the Nextcloud app Tasks is also using Vue.js within the PHP code:
https://github.com/nextcloud/tasks
Thanks a lot for help.
I've looked at the repository you mentioned and it's fairly easy to setup, the question is what would you deserve after setup? If you clone the repository you have something like a 'working copy' of the plugin. But this Plugin needs to be build and the resulting package needs to be copied to right location at the nextcloud server (or maybe you have to install the package over frontend). This is some type of plugin and not a full web application which could run standalone, as I understood.
It's not like you said:
Nextcloud app Tasks is also using Vue.js within the PHP code
It's more like PHP is used for Backend and Vue is used for Frontend, these two 'projects' are completely independent from each other (PHP is backend and Vue is frontend there are no direct dependencies). Just create your Vue application (after build you will have an index.html and several js and css files) these files have to be available from browser. Then your applications entrypoint is the index.html. For PHP: You will just define Interfaces and Routes here which will give you the possibility to interact with the serverside. Then later to deploy your plugin, you have to package it in the format nextcloud needs. You can read from Makefile in the Tasks repository what happens if package is created.
I think a good starting point for you would be: https://docs.nextcloud.com/server/15/developer_manual/app/tutorial.html

Is there any way to incorperate react with into an existing laravel 5.2 application?

I have an application built out in Laravel 5.2 with a mySQL DB, I'm trying to find a way to integrate React as the frontend framework with the version of Laravel I currently have. Is this possible?
Yes it is possible.
You can find more information in the official react docs:
https://reactjs.org/docs/add-react-to-a-website.html#add-react-in-one-minute
Definitively possible. You would be creating 2 apps: React for the front end and PHP/Laravel as an API for the data that your react app uses.

Yii framework for building API's

I have been working with Yii for some years, since version 1. I think is an awesome framework.
Today I need to build a website using Yii which includes building an API, administrator and frontend site.
In the past when I have worked in other similar projects. I shared model between them, each side (api, frontend and administrator) have their own controllers.
With Yii I am trying to find a way to organize it to take advantage of the full power of yii.
I was planning to use API only for mobile apps not for web frontend to be able to use Yii validation rules, etc and speed up the project.
Project owner wants to build a frontend which reads data through API too, that will bring duplicated validation rules etc.
If I follow project owner requirement it will be like managing 3 projects
1. Api + Backend
2. Frontend
3. Mobile
If I follow the other option, it will be like managing 2 projects:
1. API + Frontend + Backend
2. Mobile
Any advice?
Use the advanced application template, make the common directory a git subtree. Then, you can use the subtree in any number of projects. There you are maintaining only one set of models for several applications. Works great for me.

laravel or lumen, which one to choose?

I am a student and I'm making a project, an application which will show data to users on web end and also on android application. but I am confuse which one to choose for backend development, Laravel or Lumen ? My application will have signup function and displayed data from mysql against search queries. There will be 4 to 5 tables and multiple columns in each table. also images to show. So which one I should choose?
From what you have described so far Laravel seems like a perfect fit. Start off with laravel, if you need more speed and a framework focused towards building web services give lumen a try. If you haven't worked with PHP or any other backend app before, go with vanilla PHP.
Goodluck with the app!
If you only need to build an API use Lumen, otherwise Laravel
Well, I recommend Laravel rather than Lumen (Frankly speaking, CI framework may be more suitable, which is simpler and friendly to new user). About 1.5 years ago, I experienced the same dilemma, just like you. For lacking of enough document, I have to migrate my project from Lumen to Laravel when I came across some problems.

Difference between laravel 5 and codeigniter 3

This may silly question. But I am going to start new project. I am quite confused which framework is best out of Codegniter 3 and Laravel 5.
What is the main difference between them.
Thanks in Advance
Right now, I personally prefer Laravel since it supports PHP7 unlike CodeIgniter (I still haven't read if CodeIgniter 3 supports PHP7). And based on personal experience, Laravel (through Eloquent) has "beautifully-written-codes".
Here are some references for you to check out: (I made sure to post both sides to not be bias)
https://www.codeclouds.com/blog/laravel-vs-codeigniter-a-difficult-choice/
https://www.clickittech.com/developer/laravel-vs-codeigniter-which-one-is-the-best-to-use
http://www.codeigniterhands.com/codeigniter-or-laravel
http://laravel.io/forum/07-08-2014-laravel-vs-codeigniter-a-difficult-choice
https://therightsw.com/codeigniter-vs-laravel-vs-yii-vs-cakephp/ (with grades for usability)
Each framework have their own features and capabilities, used during the development of application. Laravel is one of the highly used, open-source modern web application framework that designs customized web applications quickly and easily.Laravel is used not only for big project but also best to use for small project.
Best framework in 2018
If you want a framework with exceptional performance, with nearly no configuration, not using cmd and not interested with large scale libraries and also your project is in small scale it's better to use codeIgniter.
CodeIgniter3 vs Laravel5
Both framework are good in there place.
Laravel made from multiple open source project which make laravel more efficient , reliable and secure.
Where, laravel used blade engine.
It used composer for package manager.
It provide unit testing.
It provide more security.
It provide beautiful redis queue front portal called laravel horizon.
Disadvantage : laravel used predis which is slower, because it is written in php.where phpredis is more faster, but laravel 5.* Don't support it.
I will recommend you to use Laravel beacuse of:
Built in authentication
Awesome migrations
Artisan commands to do anything in your project
Built in pagination (It's took long in Codeigniter)
Eloquent (Very easy way to interact with your database)
Relationships
Routes
Easy API building
Easy debugging
Huge number of packages and libraries etc.

Categories