Welcome Guest, Not a member yet? Register   Sign In
New World Frontend Order - how Codeigniter fit in a javascript frontend world?
#11

(This post was last modified: 04-12-2020, 03:56 AM by shinseiten.)

(04-08-2020, 09:45 PM)albertleao Wrote: As I mentioned in my post above, there IS a way to do product pages without a node server.

You can create dynamically generated routes in Nuxt with server generated html pages. This includes routes for something like "/product/some-product-name-or-id". Then you set your servers to periodically regenerate those pages. If your api is decoupled from your front end, it should be pretty easy. The downside of this approach is that product pages will be delayed to update based on how long your interval is.

I have this above system running across a few dozen servers regenerating once every 30 or so minutes and it's worked pretty well.



This is very nice thank you! I'll try the same path you described.
Reply
#12

@albertleao  if I'm not asking too much... can I see an example of what you mean? I'm struggling a little to find a comfortable structure.
Reply
#13

(04-12-2020, 04:23 PM)shinseiten Wrote: @albertleao  if I'm not asking too much... can I see an example of what you mean? I'm struggling a little to find a comfortable structure.


Hey!

Sorry unfortunately the code is proprietary and we've almost completed migrated off of codeigniter at this point so a lot wouldn't make sense unless you're very familiar with Symfony too.

I would follow the instructions here : https://nuxtjs.org/api/configuration-generate

W
e're running an elastic beanstalk stack on aws and have the cron jobs setup through there. We use Symfony components for commands to run the nuxt generate commands. I don't know what size or traffic of your site is, but if it's large, you can also offload the nuxt assets to an external source (s3 bucket is a good one). Makes your site zippity quick.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#14

(This post was last modified: 04-13-2020, 06:32 AM by shinseiten.)

(04-12-2020, 06:30 PM)albertleao Wrote: Hey!

Sorry unfortunately the code is proprietary and we've almost completed migrated off of codeigniter at this point so a lot wouldn't make sense unless you're very familiar with Symfony too.

I would follow the instructions here : https://nuxtjs.org/api/configuration-generate

W
e're running an elastic beanstalk stack on aws and have the cron jobs setup through there. We use Symfony components for commands to run the nuxt generate commands. I don't know what size or traffic of your site is, but if it's large, you can also offload the nuxt assets to an external source (s3 bucket is a good one). Makes your site zippity quick.

Thank you anyway. 

I'm working on it and i hit some problems.

1) EDIT: PROBLEM SOLVED

2) Can I create the body with nuxt but let codeigniter create the head? Or I cannot do more than 'echo view("index-in-path-generated-by-nuxt")' within the controller?
Reply
#15

(04-13-2020, 05:03 AM)shinseiten Wrote:
(04-12-2020, 06:30 PM)albertleao Wrote: Hey!

Sorry unfortunately the code is proprietary and we've almost completed migrated off of codeigniter at this point so a lot wouldn't make sense unless you're very familiar with Symfony too.

I would follow the instructions here : https://nuxtjs.org/api/configuration-generate

W
e're running an elastic beanstalk stack on aws and have the cron jobs setup through there. We use Symfony components for commands to run the nuxt generate commands. I don't know what size or traffic of your site is, but if it's large, you can also offload the nuxt assets to an external source (s3 bucket is a good one). Makes your site zippity quick.

Thank you anyway. 

I'm working on it and i hit some problems.

1) EDIT: PROBLEM SOLVED

2) Can I create the body with nuxt but let codeigniter create the head? Or I cannot do more than 'echo view("index-in-path-generated-by-nuxt")' within the controller?


You'd have to play with the output. I wouldn't recommend it as it couples your frontend with your backend. I guess it depends on how your backend is setup. Are you using your php server as an api server or are you also using it to render html?
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#16

(04-13-2020, 06:50 AM)albertleao Wrote: You'd have to play with the output. I wouldn't recommend it as it couples your frontend with your backend. I guess it depends on how your backend is setup. Are you using your php server as an api server or are you also using it to render html?

Actually I'm experimenting, I want to treat them as completely separate entities (so yes, codeigniter as apiserver), but I want to see how much I can play with this toys and how I can use them in the most optimized and comfortable way.

But my biggest problem at the moment is the pathing of the resources. In the controller I'm echoing the view that is just the index.html created with nuxt. But all the scripts are linked with absolute path and I don't understand what's the best course of actions (and the best way, I don't want to deal with a nightmare of paths and links)
Reply
#17

(04-13-2020, 09:23 AM)shinseiten Wrote: Actually I'm experimenting, I want to treat them as completely separate entities (so yes, codeigniter as apiserver), but I want to see how much I can play with this toys and how I can use them in the most optimized and comfortable way.

But my biggest problem at the moment is the pathing of the resources. In the controller I'm echoing the view that is just the index.html created with nuxt. But all the scripts are linked with absolute path and I don't understand what's the best course of actions (and the best way, I don't want to deal with a nightmare of paths and links)


With Nuxt, you have the ability to choose where your resources folder is. I'd just create a 'assets' folder in your public director and have the outputs sent there. Then you can hardcode the path to that directory. This also give you the ability to support multiple versions of front ends if you have something like /public/assets/v1.0/ /public/assets/v2.0. You'll need a little more configuration for that second scenario though.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#18

(04-13-2020, 09:32 AM)albertleao Wrote: With Nuxt, you have the ability to choose where your resources folder is. I'd just create a 'assets' folder in your public director and have the outputs sent there. Then you can hardcode the path to that directory. This also give you the ability to support multiple versions of front ends if you have something like /public/assets/v1.0/ /public/assets/v2.0. You'll need a little more configuration for that second scenario though.

I'm trying to do that and to detach index.html from the rest of the assets. Because by doing that there would be a conflict with the index.php of Codeigniter.

Or you mean the index.html should go in "/public/assets/" too? But then on the controller what should I do? Straight up include the /public/assets/index.html on the method within the controller? 

It seems a little ugly
Reply
#19

Your index.html doesn't have to be public. You can have it in your views file like you would any other php view file, the only things that need to be publicly accessible are the javascript/css files from nuxt. Sorry I can't be more specific, we're also returning views with symfony responses and using laravels blade for parsing so it's not 1:1 with codeigniters system. Hope that makes sense.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#20

(This post was last modified: 04-13-2020, 10:56 AM by shinseiten.)

Don't worry, I'll find a way and this are all very valuables information.

Another problem. I thought to have solved it but I can't find a proper way... I can create routes by returning an axios call that points to a server api. Can I do the same thing, but with data to insert into the store?
So I can cronjob only che "nuxt generate" and I don't have to create a JSON file to import.

Sorry if I'm bombarding you with questions, but I'm exploring and I can't find many answers online (I often do a lot of research and test)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB