How to Create a WordPress Laravel-Based Plugin - wordpress

I need to create a WordPress plugin. This plugin is actually a Laravel project. Why I would do that? because we are making a mobile eCommerce application and we have already a WordPress website for the company we are creating the mobile application for, so we need to plug-in the WooCommerce to the WordPress website then exposing some REST APIs to the mobile application (i.e., getting products on sale, placing orders, creating a new customer etc.). In case anyone answer will be that WooCommerce having its own REST APIs, unfortunately it won't work as it requires oAuth 1.0a as its authentication method when requests comes from a remote client, not the same machine, and the mobile app will be created using Ionic 4 and Angular 5/6 and they do not support oAuth 1.0a.
I tried to create a WordPress plugin using the standard way by downloading the laravel project at the WordPress plugins folder and I created a plugin file within the laravel root directory and within it I referenced the server.php file in the same directory which is responsible for initiating the composer auto-loader and then bootstrapping the laravel, however, it did not work for me!!! I also tried a package laraish
However, when I created a simple hello world route it does not respond!

Related

How do I make an existing WordPress blog available at a subdirectory/subpath of an existing Azure AppService website?

I have a Flask website (e.g. mysite.com) hosted on Microsoft Azure App Service. I have a WordPress blog hosted on another MS Azure App Service instance. I created this blog using the WordPress Azure Marketplace item by App Service in line with this doc. The current URL for the blog is the default app service URL (e.g. myblog.azurewebsites.net).
I want to integrate the blog into my website, so that the blog is available at mysite.com/blog/. For example, the page at myblog.azurewebsites.net/my-first-post should be available at mysite.com/blog/my-first-post. By integrate I mean make available; I don't mind having 2 different applications as present i.e. one for the main site, and one for the blog.
Is this even possible?
If so, can someone point me in the right direction or to the relevant docs so that I can figure things out?
Also, I am still exploring WordPress so the blog contains only test posts. If there is an alternative method of creating the blog from scratch so that it integrates into the website easily, I can work with that as well.

Can a wordpress website be used as mobile app backend?

I have a project where I need to make a mobile app for a wordpress website. It will have some features that are not in the web app yet. I've made some research and there seems to be ways to make api requests to some endpoints that are made available by wordpress. I am a rookie when it comes to planning a backend structure, building it from scratch, and deploying it, but I have developed new features for an existing node.js backend for a mobile app before. Considering all of this, can I use the wordpress api for my mobile app without any security, performance, or compatibility issues or should I start building a backend for it?
Thanks in advance.
Yes, we can use WordPress website for mobile application backend.
For this we need to make an API request according to WordPress structure and database structure.
A new development in WordPress is the WP-API, which allows you to output your site content into a standardized JSON API. Since mobile apps normally use an API to get remote data, using the WP-API is a great way to get your WordPress data into a mobile app.
We can use inbuilt plugins for the same purpose like AppPreser- Mobile App Framework.

Mixing Wordpress eCommerce site with external login based Vue Frontend Best Practices

I am new to web development and and would like advice about what is the usual best practices to achieve what I am trying to do.
I am in charge of writing a frontend app using Vue. This frontend will require a login to access the app. The app will be hosted on Amazon.
However we are also wanting to build an eCommerce site in Wordpress or equivalent that sits on the root of the website, (eg www.mywebsite.com) with the app accessible through a "sign in" button. If the user presses the sign in button we want the location bar location to not change from the website they are on (www.mywebsite.com), even though the Wordpress site and Vue frontend may be stored on different locations/domains.
If the site is made in Wordpress, we can get another developer to do that webpage for us, while I work on the frontend. However we want the experience to be relatively seamless between connecting to the wordpress root site, clicking on the sign in button and being taken to the Vue frontend.
Is this possible? Do both sites have to be hosted on the same server for it to work (eg an Amazon EC2 server which hosts two webpages, the wordpress one and the vue one)?
Or can the wordpress put a link to the Vue frontend which doesn't change the web location to the user?
Or (worst case scenario) do we need to make both webpages in Vue as one Vue application, some pages requiring login to access and others not?
Thanks kindly for any assistance.
So in order to use Vue and WordPress together, you can either write 2 separate applications. One for the Frontend and one for the Backend, which is perfectly fine or you can simply write a WordPress Application with a Vue Theme.
This is how this could look like:
WordPress Backend
You can use a normal WordPress backend, where you can build the architecture you want to. In addition, you need to set up the REST-API Wordpress provides. So this also means, just use plugins which support it. Otherwise, you would need to write custom endpoints. For example, Woocommerce would be a good e-commerce plugin, since it supports the API.
Learn more about it here: https://v2.wp-api.org/
Of course, you can host your WordPress installation on Amazon. Here is a good guide for that: https://aws.amazon.com/de/getting-started/tutorials/launch-a-wordpress-website/
Notice: The REST-API is available in core since 4.7. If you are using an older version you would need to install a plugin.
WordPress Frontend
In order to create your Frontend, I'd recommend you to make a custom theme. Since you are just serving static files this can be done pretty easy. But still, you don't need to reinvent the wheel.
There's a really good starter theme out there: https://github.com/EvanAgee/vuejs-wordpress-theme-starter
It comes with all the stuff you need to get started and since it is just a theme, you can simply set up a usual WordPress hosting without handling Domains of multiple applications.
In order to get the data from the Backend, you would simply make calls to the REST-API. Here's an example: https://github.com/EvanAgee/vuejs-wordpress-theme-starter/blob/master/src/api/index.js

Connecting Next.js to Wordpress

I have a fresh WordPress site set up on InMotion. I want to limit WordPress to the backend in terms of storing content and serving it via its API. I want to use Next.JS/React for the front end. My problem is that I am unsure how to connect the two.
Can anyone point me to a tutorial or provide advice on how I can install Next.JS in my site files? Where should Next.JS and its JS files reside? Once installed how can I have my Next.JS javascript files become the theme for my WordPress installation? I have searched the net but there is scant information on these questions. Thanks!
Basically you fetch data from the WordPress API (REST or GraphQL) to your Next.js or other React web application.
I recommend to not mix source code of both things - the React web app would be separate project, it is integrated with WordPress just through the API.
If you google "next.js wordpress" then you would find a few things:
https://github.com/zeit/next.js/search?q=wordpress&type=Issues
a few mentions of WordPress in this issue: https://github.com/zeit/next.js/issues/727
https://react-etc.net/entry/graphql-and-next-js-for-building-wordpress-sites-with-react-js
https://medium.com/#proposalpaul/next-js-3-0-headless-wordpress-in-production-a-deep-review-e9758d29c212

Can I mirror wordpress public REST API to my self hosted wordpress site?

I have a self hosted wordpress site, for example, www.example.com,
I can access the site's posts and other data through wordpress official REST API site "https://public-api.wordpress.com" via Jetpack plugin installed and enabled.
But I can not access "https://public-api.wordpress.com" this site in my country since it is blocked by firewall that deployed within my country.
So,my question is:
Can I mirror this feature to my self hosted wordpress site so that I can directly access contents in my local APP?
I have never used the official api, but i have used these plugins to create api for my wordpress. https://wordpress.org/plugins/json-api/ and https://wordpress.org/plugins/json-rest-api/.
The plugins are preety functional, you just need to install them and start using the REST API. There might not be too many features in them but they get the job done. for advance stuff you will have to modify the plugin to your needs.

Resources