Currently I have an app that is built INSIDE of CraftCMS plugins. I'm extracting these classes out and into an independent Yii2 framework.
How does Yii2 framework know WHEN to receive a request and process it? For example with Craft I am able to POST to /index.php?action=/ctrl/ctrlname/action&data=somedata but I'm unsure of how to do this with Yii?
I want to run CraftCMS and a separate Yii2 framework on the same server (for now) so JS will be making $.ajax() requests to the backend and I need CraftCMS to pick up certain ones and Yii2 to pick up other ones.
I decided to write a custom index.php file that would require_once $path where $path was the path to the correct app index.php file for bootstrapping.
This way in my custom index.php it would detect which app I wanted to load (based on a url component in the request) and then bootstrap appropriately.
Related
We have Rails app with Webpacker that serves just the initial HTML file, after which the client will download everything (inc. vue .js and .css) files.
Our problem is that we want to display something initial on the html so the user will feel as the site already loaded. This logic is in the main vuejs component. Is there a way to offline render this so it will be easily be embedded on our index page? instead of having to maintain and re-write this everytime?
It sounds like pre-rendering might be a better fit for you than full-on SSR. Since you're already rolling Webpack, there is a plugin that helps to that end called prerender-spa-plugin: https://github.com/chrisvfritz/prerender-spa-plugin
The idea behind this plugin is that, as part of your build process, it prerenders the resulting static HTML of your SPA using Puppeteer (i.e. headless Chrome), and drops it into your static HTML folder. It maintains links to your SPA code so it's still fully functional, it's just fully rendered by the time the user hits it.
What I'd suspect you'd want to try is the following:
Add the prerender-spa-plugin to your webpack.config.js
Configure the plugin to prerender your initial route and any additional routes that are truly static
Output the resulting files to the folder your Rails app uses to distribute static assets (HTML, CSS, images, etc)
Going the pre-render route is actually technically superior to SSR for truly static routes like a landing page or marketing pages. You won't need to mess with a complex pre-render setup on your Rails server, you offload content distribution to the static folder (i.e. lesser load on your Rails server), and you still get to use all the benefits of your SPA.
That being said, if you strongly feel like you do need full-blown SSR, the generally "accepted" approach is rolling a Node.js server (https://ssr.vuejs.org/). If you decide to go down this route, I'd keep your SPA assets in their own separate Git repo from your Rails server and manage DevOps appropriately.
Good luck!
BigCommerce has a node.js app which allows you to do Stencil development locally. Part of the simulation it gives you is URLs like http://localhost:3000/cart.php for the shopping cart page. I'd like to understand how this is done and where the cart.php file could be found.
The .php files are not available for editing; these URLs are merely proxied from BigCommerce servers when you're using the CLI.
Essentially, stencil-CLI gets the data from the cart page which is then compiled via node into the HTML output (using your local template).
To my knowledge, accessing php portions of BigCommerce to post changes is not really possible. It's the same for checkout.php as well. You'll have to post changes via scss files or via using handlebars and/or js-jquery.
Here's a similar question from BC forum:
https://forum.bigcommerce.com/s/question/0D51B00003zd4GSSAY/editing-a-php-page
I'm starting the migration of a Yii PHP framework to Angujar2 (typescript). The PHP framework is very big so I'm searching for an strategy for both of them to coexist while migrating little by little page by page.
My question is if there is a way of redirect routes from angular to an external framework, for example using #RouteConfig to redirect routes containing "/php/" to a given folder.
Thanks!
Routing in Angular is executed in the browser without reloading from the server. Routing just replaces components by other components while staying on the same page and updates the URL to reflect the navigation but doesn't load a new page from the server.
I have this reactjs webapp - http://52.26.51.120/
It loads a single page and then you can click links to dynamically load other boards on the same page... such as 52.26.51.120/#/b, 52.26.51.120/#/g
Now the thing is, I want each of these to be an individual page, for the purpose of seo. I want you to be able to google "my-site.com g", and you will see the result 52.26.51.120/#/g. This obviously cant work if you are using reactjs and it is all on one page. Google will only render and cache that main page (can it even render that page? does google execute javascript?)
Even more specifically, id want something like my-site.com/g/1234 to load a thread. There could be a thousand threads every day, so im not sure how to handle that.
Are there any solutions to this? to allow react to possibly serve up static pages as html so that they can be cached on google? I am using expressjs and webpack as my server right now, and all the code is executed in jsx files.
Thanks
You can use Prerender.io service. In a nutshell you will need to connect your server app or web server with prerender service and do little setup (see documentation). After that search engines and crawlers will be served with a static (prerendered) content while users will get classic React.js (or any other single page) app.
There is a hosted service with free tier or open source version
I suspect you could do some smart configuration with nginx and it could convert a url of domain/board to a redirection of domain/#/board when detecting the user-agent as a bot instead of a typical user.
My problem is I want to integrate Durandal witha Wordpress site yet Durandal expects HTML files as views. How can this be changed to use PHP files?
Yes. A php script generates dynamic HTML files on the server. You would just need to generate HTML that is valid within the context of Durandal.
The strategy is similar to using Durandal with ASP.Net, which would be a good place to start looking for tutorials.