How to install React Js with CodeIgniter..? - javascript

Possible duplicates:
Codeigniter and React.JS setup
React.JS setup with Codeigniter
how to implement react js in codeigniter
ReactJS not rendering php codeigniter
Above given links are not working properly.
I followed the procedure to install React Js using facebook-create-app in windows, it works perfectly. But i need to work React Js with in
CodeIgniter. How to install and run it..?

CodeIgniter with React
CodeIgniter code is little bit changed to accommodate theming structure. Also there are significant changes done and some are in progress, to support rendering using React JS.
The changes are done in such a way, which put this repository in the state, in which it can be used in multiple ways, the default being rendering the views using React and it supports the default CodeIgniter views also.
Here you can find much more infos : https://github.com/kala725/CodeIgniter-with-React
Second one
Another example which I tried two years ago I think : https://github.com/Jineshfrancisco/React_Vue_Frontend_Scaffolding
download the repository from github
extract into your codeigniter project folder
link css and js files in public folder into your view file
edit the package.json file and other (watch the Video)
run the command "npm run watch" or "npm run prod"
video tutorial explains almost all you need on youtube : https://www.youtube.com/watch?v=-ba6y3r69VE
Codeigniter + Reactjs – Integration
See this tutorial is well for step by step https://www.tutofox.com/react/codeigniter-reactjs-integracion/

I am using React+ CodeIgniter for a small personal project I am working on currently. React is wonderful for creating dynamic, interactive front-ends. PHP developers are available in plenty to develop the REST backend, with the added advantage of very cheap, shared hosting. Some simple "formsy" admin pages are also done in CodeIgniter, making my bundle size smaller and maybe some added security.
You need to first build the create-react-app project using
npm run build
When it finishes, you will find the 'index.html' and other required files inside the "project_folder/build" folder. Copy everything into the Apache htdocs folder. I put the codeigniter files into "htdocs/api" folder. You will need to do some redirects with '.htaccess'.

Related

How to render .astro files in django

I tried to create a Django web app since the web pages had heavy js files so it took a long time to load the page. To tackle this problem I tried to implement Astro to create a static webpage.
But the problem here is that Django renders .astro files also as HTML.
How do I tell Django to render .astro as an Astro file
Astro is a static site generator built on top of node.js. To have your static site served from your django application you would first need to build astro out, using:
npm run build or yarn build to have your site output in the ./dist directory. From here you can then point your django server to serve those files.
Since Astro files are static they can be deployed in a number of different ways, you can read more about this here
Hope that helped buddy, if you got any more questions you could always come and ask them in the discord channel

Deploying multiple React applications in one Node.js server

I have multiple portfolios made in React and each one of them has their own Node.js API.
I'd like to gather all frontends in only one domain so all I would have to do is using "/name-of-the-project" for each one of them. I did the steps below:
Created a new Node.js server that will work as a "general server";
In this general server, I set the folder public to be used for static files;
Built any of the React apps (npm run build);
Moved the deploy codes to the public folder of the general server;
Set the cors() in the API's (the ones I mentioned React apps were built with) of the frontends to allow requests from the general;
An example of how the general server became with a React deploy:
When I access http://localhost, it works. But remember I said I had multiple projects? So I created folders inside the public folder to put each React deploy in their respective folder. Let's say:
Now if I enter http://localhost/frontend-1, for example, it doesn't work
What I tried to do before creating this question?
I created a simple index.html inside each folder and they work. Only React deploys don't.
If it helps anyway, this is the general Node.js code:
I think what you are missing is the setting up the basename's of each of the react apps that you have.. I assume that you have routing in each of your application, with that you have to update its basename to point into the right directory/url.
I had a similar issue. I was building an e-commerce store with 2 separate apps - customer and admin apps.
I believe in your case the issue is that the npm run build doesn't have the relative path.
For instance, all the static files like .css in frontend-1 app should be prepended by /frontend-1 and same for others. \
To do this update the build script in your individual react apps and add PUBLIC_URL. For example in this code block i have added that for an admin app.
For more detailed explanation you can refer this youtube video.

How to use external repo in an another repo in angular 4?

I have my own repo which has been written in angular 4. Now I need to use an external repo in my project. So I can do it easily through importing the external repo as a library in my project. In this case I need to build my project every time when the external repo got modified.
But as per my requirement, I need to use that external repo in my project without building it every time.
So using the external repo as a library is not a good idea as per my requirement.
Is there any other way to use it ?

Why my React app is not loading correctly (broken) in localhost?

I had my react project working correctly in localhost. Then, I decided to deploy it to github pages and it worked perfectly on the server too. Now, I'm trying to work on it again on localhost but it is not showing correctly. For some reason, photos are not loading and some css is not working correctly and after compile it in PowerShell says this:
Compiled successfully!
You can now view myportfolio in the browser.
Local: http://localhost:3000/myportfolio
On Your Network: http://192.168.56.1:3000/myportfolio
Note that the development build is not optimized.
To create a production build, use npm run build.
So if I go to my GitHub pages it is loading correctly but not in localhost (running npm start).
Any suggestion? Thank you in advance and let me know if you need more clarification
I did clone your repositories and found these problems:
You have been directly imported many third-party js given their relative path in the index.html. That doesn't work. You should append %PUBLIC_URL% before them. For e.g.
<script src="%PUBLIC_URL%/js/jquery.flexslider.js"></script> and similary for other script files.
But even this is not the best that you can do. You must not try to use jquery or third party js in a React App. Also, make it a part to install the related JS though npm and make them a part of the package.
You'll have to use <img src={require('/public/images/background.png')}... (Btw, the image name on your gh-pages is different. It's logo.png there)if you want the webpack to compile and make it a part of your project. Also, the path must reside within src and not public folder.
Other errors are are related to keys. Whenever you're mapping and iterating through a list in react you must specify a unique key.

Meteor integrating bought theme/js freezes meteor server

I have a bought One ui theme that I'm trying to integrate into Meteor.
I have browsed stack overflow for the solution for hours and I'm stuck.
I have copied the complete assets folder into a newly made imports directory on the client side and tried to use import on the client main.js to import the modules I need. The problem with this is that when I run the server with meteor --port xxxx it hangs up on building web application and just freezes.
I have also tried putting it in a client/compatibility folder for the javascript and it doesn't seem to work.
Does anyone have any insight into this?
For the static html I just created a new template with the html and that worked.
Client/lib is where you put your JS libraries.
rootproject/public is where you put your static assets(images/fonts).
Look for packages on atmosphere.js and check if they are compatible with what you're trying to do. This is the most confusing step because the package names will not exactly be the same as the third party js libs. Trial and error.
Any third party js files you can't find on atmosphere.js you dump the js files in client/lib.

Categories

Resources