I am currently using AngularCLI to generate an app for me. When starting npm serve is starts its own server. However, i need to integrate PHP / MAMP and thus it uses it's own web server.
What is the best way to link the two? Very little info on Google but I am probably not searching for the right terms.
first of all, to host your app on a mamp-server you just need to:
ng build --prod
and then copy the files in the dist-folder to the root of your web-server.
But Im guessing that you then want to read and write from the database.
This is my recommendation:
Dont put php-tags in your html, make web-services
e.g. make php-scripts that get data from the database and outputs the as json, then use HTTP to get the data to your Angular-app.
Add root url (hostname) into build js links in index.html,index.html not understand to .css .js files in build folder in hosting time.
Related
I am 'new' to PHP so this question probably has a very obvious answer, so Ill apologize in advance.
Situation:
I am running a VueJS project, running it with npm run serve and then deploying it with npm run build to a laragon apache server with PHP 7 on it.
That all works great.
I am now moving from using our C# API which we have hosted and you hit it as a URL. To a PHP Api, this API is just set up with a straight connection to SQL using sqlsrv_connect. This is also working when I host it on apache/laragon in its own folder and hitting it on its own URL extension.
But what I was wanting to do ( and not sure if this is possible )
Is in my VueJS project put the .php files in a data folder and hit them like this fetch("src\data\GetSQLData.php?table=Clients&columns=top%2010ClientID"")
Is this possible, or should I rather have them hosted separately and use the URL method?
Buddy,
Vuejs is a front-end framework.What it means is, When you do npm run build then it will create bunch of js and html/css/image files on the server.Then you require a web server to server these files.
When you hit the url on your web-browser then all these files will download into
the web-browser and then execute over there.This is how front-end framework works in a nutshell.
PHP is a back-end scripting language.Which means it require back-end php engine to run and execute the code logic.So it has nothing to do with vuejs that is running on your web-browser.
Best possible way to connect these 2 applications is via API.You should request data from a php API which is running on back-end web server.
fetch('http://localhost/GetSQLData.php?table=Clients&columns=top%2010ClientID')
I have just created a simple REST Api following this small video using Slim Framework 3.x. I was just getting started and I followed the instructions in the video and created a simple route like this
$app->get('/', function($request, $response)
{
return 'Home';
});
This works on localserver (XAMP) when I open the link `
localserver/project_name/public/
` I get "Home" returned on the page.
After that I simply Zipped the project folder and uploaded it to my Web Hosting, htdocs folder. I extracted the zipped project, which included the "composer.phar" and "vendor" folder. I try the same thing again, i.e., I run the url
www.mysite.com/project_name/public/
All I've done is change "localserver" with www.mysite.com but the browser tells me that my domain
is currently unable to handle this request.
I know this might be something very obvious but I am a novice in php and REST Api's. So any help is appreciated. Also some things I think might matter are, The web hosting that I am using is Plesk based. I have a mysql database Running on the hosting and simple php files run when run individually. For example if I run simple call a test.php file with some database query in it and some echo, it will run successfully. Even if you can point me in the right direction, I would appreciate it. Oh, and I don't have access to php.ini on the hosting. I was only provided with one login that lets me login to the hosting and I can see htdocs folder among some others. I have attached an
image of the view I get after logging in, to give you more perspective of the type of hosting I have. I am hosting a website in the httpdocs directory as well. ASP.NET developed
I just need some direction as to what I need to do to be able to publish my REST api to my hosting and be able to access it through this android app that I am building. What do i need to do on my server? What settings to change to make the api work?
I am totally new to Flex mobile developing.
In FlashBuilder for PHP, you need to specify local PHP server.
My answer is, how to change it to remote server?
Because, i have a hosting, and I need to put files there, to make it public.
You never need a local server per say. Have you tried to look at the files that Flash Builder creates for you (if I remember correctly, in this case it creates a service-config.xml file)? There should be one that mentions ServiceObjects and an endpoint of localhost. You can change this to your remote location.
I personally don't like the xml approach to creating services since it doesn't give me the flexibility I want in the code. I much prefer having it in the code using the ServiceObject class and specifying the endpoint and destination there and using a delegate pattern to call my services. Something for you to look into :)
For javascript and html files only, Dreamweaver's build app for android function seems to work great in cs 5.5. But when any php code is put in (for authentication, or for ajaxing in web service returns ) it seems that the android app just displays broken php code instead of executing it. When building the app, Dreamweaver won't even let you use a root php file in the project; it only seems to only accept html files.
Am I doing something wrong? Building apps out of web language-based files seems a lot less useful if server-side code isn't allowed.
Are there any other alternatives? Titanium studio looks really complicated, but I'm willing to read the docs if it's worth the time.
http://help.adobe.com/en_US/dreamweaver/cs/using/WSeffff8bffc80208478c8d43312e240fe0ad-8000.html
Indeed it only packages HTML, CSS and Javascript into an Android or iOS package.
I'm afraid you'll have to learn real Android development if you want something more complex.
Dreamweaver will package the files up just like you asked, however, the destination system is what runs the code. Android doesn't execute the PHP within the app. Your app has to connect with a remote server that is to handle the log in. Thinks of two separate apps, one on the phone and one on your server.
Android doesn't execute the PHP within the app. This is because PHP is a server side client and Not client side. Unless they create some inbuit servers within phones from which native apps can tap into. One option you can use is to use html files and within them, create links to php files which are in online servers so as to have your scripts executed.
I'd like to know if the following situation and scripts are at all possible:
I'm looking to have a photo-gallery (Javascript) webpage that will display in order of the latest added to the Dropbox folder (PHP or Python?).
That is, when someone adds a picture to the Dropbox folder, there is a script on the webpage that will check the Dropbox folder and then embed those images onto the webpage via the newest added and the webpage will automatically be updated.
Is it at all possible to link to a Dropbox folder via a webpage? If so, how would I best go about using scripts to automate the process of updating the webpage with new content?
Any and all help is very appreciated, thanks!
If you can install the DropBox client on the webserver then it would be simple to let it sync your folder and then iterate over the contents of the folder with a programming language (PHP, Python, .NET etc) and produce the gallery page. This could be done every time the page is requested or as a scheduled job which recreayes a static page. This is all dependent on you having access to install the client on your server.
You can try this : http://forums.dropbox.com/topic.php?id=15885
You can use the (alpha) tool autodrop, wich is just that: a simple gallery frontend that uses images in Dropbox.
As said: alpha. I am still developing it, rewriting it and making it a little prettier and nicer.
Written in Ruby, using dropbox, sinatra and HAML gems. So you will need a host that supports Ruby apps.