Codeigniter and ReactJS |
02-20-2023, 04:57 AM
(This post was last modified: 02-20-2023, 05:20 AM by kenjis. Edit Reason: Remove BB tags )
For my new project, I want to use Codeigniter and ReactJS. What's the best way to set up the project directories and convert .jsx files to .js? How can I concatenate and minify all .js files to be min.js? Should I use GruntJS?
I find the simplest way to get started with something like React is probably using ParcelJS to handle your javascript dependencies and building the files, etc.
Setting up a Codeigniter and ReactJS project can be done by creating separate directories for the frontend and backend. You can have a "frontend" directory for all your ReactJS code, and a "backend" directory for your Codeigniter code. To convert .jsx files to .js, you can use a build tool like Webpack or Babel. These tools can also help you concatenate and minify all .js files into one minified file. GruntJS can also be used for this purpose, but Webpack or Babel are more commonly used for ReactJS projects.
To get started, you can create a basic ReactJS project using Create React App, and then integrate it with Codeigniter. You can then use Webpack or Babel to build your ReactJS files into a bundle that can be used in your Codeigniter views.
Thank you for sharing the steps to set up a Codeigniter and ReactJS project. I have a couple of questions:
Are there any specific steps required to integrate ReactJS with Codeigniter, or is it just a matter of creating separate directories for the frontend and backend? Can you recommend any resources or tutorials that provide a more detailed guide on how to set up this type of project? Thanks again for your help!
Making a simple ReactJS project with Create React App and then integrating it with Codeigniter is a great way to start. After that, you can compile your ReactJS files into a bundle and then use it in your Codeigniter views using either Webpack or Babel.
I never understood this. The same seems to be happening with Laravel. As a business solution developer, in my opinion, the best flexible and maintainable approach would be:.
(1) A separate front-end (not integrated or embedded) Where the app can be developed for mobile or Web. These can be created by using pure web stack or frameworks like React , vuejs etc These apps can interact vide API calls to the back-end (2) A separate back-end In most instance these would represent an API Server, headless CMS or an Admin system for the backend. These can be Python, pure PHP, Codelingiter or even Laravel (overloaded). Using the bundled approach will lose all the flexibility of locating apps, separate maintainability, decoupling software, localization and separation of functions. Just to my views.
Hi
Sorry to bump but I'm still trying to figure out how to integrate a ReactJS landing spa into codeigniter, which is already working (it is not an api, it is a full web app). I must figure a way to load the static site (index.html generated with assets etc. in dist folder) as a main page/route without having to modify Apache's virtualhost (that points to codeigniter public folder) Any ideas?
Enrique
https://beza.com.ar
What is the problem? You can't open it public/index.html ?
However, I do not know how the routes from React will work together with CodeIgniter 4, but most likely through the URL in browser (08-13-2024, 10:51 AM)ozornick Wrote: What is the problem? You can't open it public/index.html ? I'm trying to figure out a way to make a ReactJS landing page (with its own assets js css etc.) to work with an already production CodeIgniter app. This landing should replace the codeigniter's "/" route. The landing only contains info and 1 link to the codeigniter's "/login" route. Codeigniter's virtualhost config is set to its /public folder and can't change that because this will make codeigniter urls to change. I mean, can't move this codeigniter to a subfolder like mysite.com/app If I can't get this to work in any way, I'm afraid I'll have to convert the ReactJS landing to BS5 and integrate it into codeigniter assets, views etc. and will take tons of time Thanks a lot in advance for any idea/tip you may have to make this work
Enrique
https://beza.com.ar
Try move app in subfolder. https://codeigniter4.github.io/userguide...plications
Otherwise, your public/ will be like a regular folder on the hosting. Without job of the framework. All requests will be sent through the new example.com/ci4/ folder |
Welcome Guest, Not a member yet? Register Sign In |