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')
Related
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 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.
We have the following setup - remote repository with gitlab gui.
Our webserver is located on another server and we have ssh access to it. We also have local copies of our dev site, our git setup right now just push to the repo in gitlab.
My goal is to automate the process and on every push to gitlab repo to update the server dir with latest changes.
I saw that for this purpose we should use webhooks or deploy keys. I want to avoid using cron job.
I created a bash script which performs git pull after certain php file is accessed.
However when I placed the url to this php file in webhook section in gitlab, nothing happened.
If I access the file manually by typing url in address bar it works ok.
When I try to test the hook I get 500 error and timeout.
Any recommendations how to improve this process or where Im going wrong ?
The webhook does not just sends a get request to the provided URL, it also sends its data as JSON in raw data.
Can your script handle that?
Have a look at gitlab-webhook-push.php
The actual issue was that gitlab was not able to access our domain and was leading to timeouts, of course sys admins decided to restrict the access from external sources without notifying. Also it is good to mention that JSON raw data can be used for more complex solutions which is pretty nice.
I have an existing PHP app working on an Openshift application which is saving some files into the "DATA" directory.
Now I am migrate the same code to nodejs and I am putting it on another OpenShift application (in the same OpenShift account and domain).
What I would like to achieve is to have the PHP application writing files to the "DATA" dir of the nodejs application to keep existing and working PHP code running and creating files, but consuming those files from the nodejs app.
In the future I can plan to migrate existing and missing PHP code to nodejs as well.
Thank you!
Best regards,
Camillo
This isn't going to be possible. The DATA directory is local to the OpenShift gear. You can't even share a DATA directory between multiple gears of a single scaled application. You would probably be better off switching to a distributed file system such as Amazon S3 or Dropbox that both applications could access.
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.