Questions about building a large spa

Source: Internet
Author: User
Tags php write
Do you use Angular.js or Vue.js or react.js in all stations? Want to use the spa and back-end PHP to complete the project, do not know how feasible? If you use the spa, how to deal with some data interaction is to use AJAX or call the stateless API to interact with the data, how to deal with cookies and session problems.

Reply content:

Do you use Angular.js or Vue.js or react.js in all stations? Want to use the spa and back-end PHP to complete the project, do not know how feasible? If you use the spa, how to deal with some data interaction is to use AJAX or call the stateless API to interact with the data, how to deal with cookies and session problems.

Try to talk about my thoughts:

    • Does the stateless API mean that the user is not authenticated? If this is understood, non-sensitive information (such as a relatively fixed large association drop-down list) can be used with stateless APIs.

    • The SPA front end should not need to use cookies directly (refer to the next article), the session to the back end of PHP processing, the cookie contains the necessary information in each XHR request will be submitted to the backend.

    • PHP side and traditional development is not much different, it should be easier to say, no longer need to consider the problem of rendering, basically each request is output a JSON to end.

    • Front end you can use Localstorage if you need to save some information for the next time you open the page.

    • For a large SPA front-end router should be very important, need to be carefully treated a link bar. Because the user may bookmark a URL that is not the initial entry directly next.

    • If you need to take care of a low-provisioned device (such as a small-memory Android phone or a PC that's still 10 years old and barely running XP), it might not be a good fit. But SPA apps tend to be more avant-garde and may not face this problem.

Angularjs do the development of single page application is absolutely no problem, our company is using Angularjs+java. Java provides only data (JSON) interfaces (restful). Angular.js's $resource services, such as Ajax, use lingering objects to solve problems such as callbacks. Angula.js application to pay attention to layering, is similar to the background of MVC, each layer of functional clear, so that the whole project will not be confused. can go to find a template program to see, according to the template changes to their own project, in NPM search generator-beginning of the project.

If all use angular, full ajax, that SEO problem can not be avoided. If it is a cookie you can see how to store Ngcookie on the website API

If the site is in a mobile station, you can fully consider the spa

The rare earth nuggets seem to be all over the station, Vue. You can look at it.

Worktile is the spa, you can see the team collaboration Tools Worktile technology Architecture Secrets

In addition, the larger the SPA project, must have a good file structure, as well as automated configuration. Here have to mention the F.I.S of the angular project seeds, very good, worth to see

Login Returns a token
Then you need to use the user's identity, pass token
So you don't need a cookie or a session.

The whole station of the spa to write small projects, the use of Reactjs, and background interaction using superagent, in fact, Ajax, authentication at the time to check a lot of information, and finally after landing in the background to save an identity, return token, and local preservation, Each subsequent request to take token and verify, and then return to the new token, this is actually a big problem, but the other way is more or less a problem, but since the intention of the restful, personally think that directly on HTTPS is the most convenient.
About the front-end separation can look at me this (but the background is java.) : Http://git.oschina.net/oneayst/springmvc-shiro-react-redux-restful-example/tree/master

By the way, a discussion on the identity verification in the restful, you can refer to
Http://stackoverflow.com/questions/319530/restful-authentication

Say that the spa does not mean to completely achieve a stateless. (I seem to be off the topic)

Certification? It would be nice to use the session as usual. Ajax is also with cookies.

Mobile has a lot of spa, in addition to the problem of SEO can be based on the framework of the service-side rendering solution,

I recently used Riotjs to do a spa e-commerce project, PHP write rest service, rest service provided to front page and Android client call.
Use Riotjs to build the entire project, including home page, list, details, shopping cart, order, and login pages.

Angular.js is the framework for the spa, is the SEO some small problems, but can be solved by other means.
Vue.js still good amount, do spa also can amount, I see UC Many applications use this to do the bottom frame, mobile is still good

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.