简体   繁体   中英

How to use ReactJs and Symfony without webpack config

I am working on a project based on rest api (FOS Rest in Symfony) and React Js. I have followed following tutorial Code Review Video .

It's amazing and gave me very fine concept for working with React Js with rest api . I also read Limenius/ReactBundle and some other bundles which are manly based on webpack config .

While using webpack config there is two server for running the whole project. first is symfony server for Rest Api and other is webpack server(node js) for React Js.

Is there any way so that the project(with both symfony + reactjs) can run on same server .

If it is please kindly give me idea .

Thanks in Advance .

react.js is only a javascript library.

Just link in the library files with something like: (Im using twig to template in this example)

    <script src="{{ asset('bundles/app/external/react.js') }}"></script>
    <script src="{{ asset('bundles/app/external/react-dom.js') }}"></script>
    <script src="{{ asset('bundles/app/external/browser.min.js') }}"></script>

as you would do with any other file.

There are plenty of resources that give full instructions on which libraries you need in order to get React working, but these are the 3 I use.

A trouble I've personally found with lots of the front-end resource tutorials is they get all hung up with node, bower or any number of other 'package managers'. The truth is, you dont need any of them.

Symfony is just a set of PHP libraries, React is just a javascript library. Theres no magic that needs anything else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM