Vue.js (CLI) + PHP - php

I'm relatively new to practical web development, so I apologize if the question is stupid. The crux of the problem: I only want to use Vue on the front end of the site, and on the back I am using a PHP framework (or not a framework, it doesn't matter). Connecting Vue to every page via a CDN seems to be wrong to me. I didn't quite understand how the CLI works, does it generate some kind of static files (like a compiler), or does it definitely need Node? And did I understand correctly that I can't use things like Vuex and vue-router without node.js? Thank you in advance!

VueJS and vue-router are totally independent JavaScript framework and router, you do not need NodeJs to use them, you might get confused after using npm but npm is just a package manager, using it is a matter of choice.
The ClI or currently #vue/cli is just a command line that you can use to create new projects and control them, run them etc, using it isn't required when using vue trough a CDN.
About PHP:
There are a lot of ways to use VueJs in PHP but the most convenient one would be creating a PHP API in the back-end and a normal Vue and Axios app in the front-end, this approach is the one you should get used too because its easily implemented in other languages and even PHP frameworks, for example WordPress.

Related

Android App using HTML template with jQuery

The question is very basic, but it's very important for me. Please suggest me a solution. I have some mobile app template in HTML/ jQuery. I want to create Android app using the template. What will be the best choice for the back-end language. Database is MySQL. I have 10 years of experience in PHP. But I found PHP is used mainly for web, it is not suitable for Android app. So, please suggest what language should I learn and which IDE should I use. And finally is there anyway I can use PHP for developing Android App?
Node.js might be an alternative for the back-end, because it's still included with javascript and supports mysql
For both hybrid and native apps, you will probably need to develop an online API the app can use as a backend. That API will not run on the mobile device but on a webserver somewhere and can most definitely be built using PHP/MySQL.
For the app itself, if you want to be able to use your HTML/jQuery template, you're pretty much limited to a web app or hybrid app. These render your UI in a browser context so they're capable of loading and runnig jQuery code. You will probably have to learn about service workers to handle on-device caching so that your app stays functional when the device is offline.
For a native app, your best bet IMHO is to go with React Native. You cannot use your current HTML/jQuery template for that, since native components do not use HTML or Javascript (or CSS for that matter). But, in React Native you can rewrite the HTML part to use JSX components which are pretty similar. All the jQuery logic would have to be re-engineered "the React way" but will still be Javascript. The React Native compiler will take care of converting that JSX/CSS/Javascript code to native Android components.
It depends on you but i will suggest you if you want to expend your skills in applications development try to learn ReactNative

Best way to integrate a react fuse template in php codeigniter

We have an app using the Codeigniter framework, and we are trying to connect a Fuse React Template Fuse React to be used as the view of the application.
Which way would be the best way to integrate the react build into the php code base?
We first thought that it would be easy to just use a react_view_controller. Similar to this:
How to integrate Reactjs frontend with php codeigniter application on apache server?
but it seemed confusing to import the files into a script one by one since they are coming from a well structured template.
Then we thought we will build out the production build and mount that into the php codebase.
How do we configure php to look at the react-build files?
Anyone have any resources I could look up?

Using Django on Laravel?

I recently started on a project using Laravel and I'm curious to know that if I can consume Django web services on Laravel.
I tried searching google but all that came up were comparisons on it. I want to know if there are any struggles or issues when integrating a python api for php.
(ps. I'm clueless to a lot of these stuffs so am sorry if somethings aren't clear to me)
If you want to with your Django program from within Laravel there are 2 possible ways of doing this:
Guzzle, PHP HTTP client - This will allow you to get and posts from within PHP: http://docs.guzzlephp.org/en/stable/
The Symfony Process Component - which allows you to execute python code in from within PHP and get the anything that is returned: https://symfony.com/doc/current/components/process.html

How to bootstrap/setup Angular2 in an existing Laravel project?

I am looking to implement Angular2 inside my current Laravel project. I've read about many setups including AngularClass's version with Webpack, but I feel like it's all over-complicated.
What I wish to make:
A simple single page app inside my Laravel app.
It needs to have something like Grunt/Gulp or even Webpack to compile upon changes.
Does not need NodeJs to run in production, no lite-server, just like AngularJS it can be injected and that's it.
I need to understand the implementation files to achieve this, so no starterpack or angular-cli, unless if you can supply good arguments.
Looking for a "how to"-like example on creating the above.
Thanks in advance.
EDIT: More information
As ANKH pointed out, i needed a more detailed and coursed question. So here we go:
- Looking for a example implementation of a Angular2 based SPA inside an existing PHP application (Laravel).
- I've tried many different tutorials, going from the heroes tour, to Sitepoint and AngularCLI based tutorials, but they all assume a SPA on it's own. Ergo, they are compiled and served through NodeJS, which I don't need.
Turns out that I've actually been looking at this entirely wrong. I've gone with using Angular-cli and found that I could generate the output files and include these inside my Laravel project. No need to integrate them further.

React.js and PHP together?

I'm looking to rewrite an old website using React.js for my frontend framework and PHP for the little backend stuff I may need.
The server I'm using is IIS with Apache, but I have little/no SSH access/ability to install stuff on the machine (i.e. npm, node, etc.), so I'm restricted to using PHP as a backend (so I can't build/compile my React JSX serverside). However, couldn't I simply just upload built/compiled my react files to the server?
I have seen this, but I'm not entirely sure that I need it?
Basically, my question is, is using these two together practical? Would I need any other tools to accomplish this? (The website is likely to be pretty small.)
I've used PHP and React together briefly (and then moved on to isomorphic React). Running V8 with PHP is only useful if you need server-side rendering (for fast initial loading and easy SEO), but I've not tried it so I'm not sure whether it's stable/reliable enough. If you do not care about server-side rendering, then you can just build the React app and include it in your PHP view.
Basically, the PHP view would serve as a layout, with a React container element defined so that your React app can bootstrap with it.
You can also pre-fetch the initial data for the React app with PHP and somehow attach it to your PHP view. The simplest way would be to use a script block to assign the JSON-serialized data to a global variable. Another way would be to define element(s) and attach your JSON-serialized data as element attributes, to avoid globals. Either way, you'd have your Flux stores bootstrap with those initial data to avoid having to hit APIs before the app can load.

Categories