I am sorry for this such question as I am still a fresh beginner in Phonegap.
I have followed some tutorial both for the installation and the jquery.mobile usage.
There are some parts (the biggest part) that I am confused with this Phonegap. And it is about the directory structure.
I am working with Private PHP Framework from my department, that is why I used Lamp Stack for all of this.
However, with the Phonegap tutorials I have been following this far, it looks like it have a little bit different environment structure from usual. It have five default directory as follows:
Hook
platforms
Plugins
www
In where the working directory for this Phonegap must be in the www directory.
It makes me afraid because our Apache Environment require us to put the directory in costume folder (Not in var/www), and then also the PHP Framework require us to put the module in a specific folder.
Please, I just need an enlightment for this Phonegap, how do you access the files and where do you guys put it.
Many thanks in advance.
As requested:
Create another vhost that points to www. You don't need to worry about hook, platform and plugins which are cordova/phonegap folders. Let them all at the same level (don't change the structure, just point the vhost to www).
The structure of cordova/phonegap is simple. Inside the www folder will be all your programming logic to build yours mobile app.
But beware, the cordova/phonegap does not compile code in PHP, it just uses a webview (like a browser) to run your mobile application developed with HTML, CSS and Javascript, packaged in a apk with access to native features of the smartphone/tablet, basically.
To make your application to communicate to the server in php you have two alternatives:
1) Making your app to access a URL that points to the application
developed with PHP and render its application in webview.
2) Create all purely on HTML, CSS and Javascript and make
communication via ajax, or socket or something similar to the server.
Related
Essentially, I'm looking to have a PHP development workflow that needs to be modular, but using a Single Page Application technology.
I understand it is recommended to separate the back-end from the front-end. Develop them separately. But is there a way to group all related code into one module (or folder), meaning all backend code with its own views presentation inside the same folder?
It's like MVC, but the "V" contains fragments of vuejs (or angular) files, which extends from a master file somewhere in your project.
For example
Assume we are building a modular CMS, where you can upload "plugins" (really, PHP modules), extending the CMS' functionality:
-project[root-folder]
----core[folder] # contains all infrastracture code, api routes, master view file, magic, etc.
----modules[folder] # uploadable modules goes here
--------User[folder] # sample module; follows the MVC pattern
------------Controllers[folder] # contains files, e.g. UserController.php
------------Models[folder] # contains User.php
------------views[folder] # where vue components is housed
----------------users/index.php # contains vue code
----------------users/create.php # etc...
----------------users/js/user.js
----------------users/css/user.css
--------Blog[folder] # another module
----index.php # the master view or just the bootstrap file
----gulpfile.js
Then inside the core/ folder, there is a master layout that binds all views together.
Will a folder structure like this be viable?
Obvious problem there is you can't use .vue files (as that would mean, every time you upload a new module, you need to run gulp or re-compile).
Hoping for your feedback. Thanks.
This question will strike a lot of folk as bizarre and twisted. That's the reaction I got when I asked it in the context of .net mvc. I'm with you 100%.
I'm too new to js frontend development (and too ignorant of PHP) to have much advice. It's going to be tricky. Ajax calls to PHP code will need to go to paths below the src directory. But then you want to stop your frontend resources being served from these same paths. Both PHP and gulp will want to use file paths for urls, but at least for Gulp this can be controlled.
I'll follow this with interest. My ambition is to keep in the same folder things you're likely to want to delete together, and for those things to be able to call each other with short, relative paths. The ideal would be to be able to specify the module route independently of the path on disk, and to have this route work for both frontend bundled resources and services. Good luck !
I came across this question whilst searching for an approach for exactly the same problem. I'm building a "platform" rather than an application with a plugin system along the lines of Wordpress. I have the additional issue of the platform itself being a 'multitenancy' environment, too - so any plugins cannot interfere with the core "Dashboard" that holds these things together.
So; posting for a few reasons, two years on...
Did you get anywhere and would you care to share any thoughts?
I came across a quite extensive article for PHP Phalcon that has certainly given me a few ideas. Sharing incase it helps you/others:
https://blog.antsand.com/singlepost/index/5619/How-to-integrate-php-(Phalcon)-and-Vue.js-components
There's a line buried in the series that says "As a rule of thumb. Structure your code, based on the application and NOT on the programming language and frameworks." I'm not sure how wise or not this is, but it certainly gave me something to crack on with.
So right now, I have a module folder a bit like:
/mymodule
/Controller
/Model/
/Template
thing.vue
/Assets
/js
/css
MyModule.php
Assets are handled via a framework route (i.e, /assets/{path:.*} )
Templates are handled via the (PHP) module install script to make sure webpack knows where they live.
Still at proof-of-concept stage but rightly or wrongly, it seems to work well enough!
I have a PHP framework. Recently I've put some burden on NODE.js shoulders. Now I don't know where to put node.js files. For now I have one file, but It'll get bloated in the near future. Where do you suggest to put these files?
Thanks in advance.
EDIT :
I'm asking to see if putting nodejs files inside the php framework best practice. Or should we put all nodejs file in www folder without ever caring about our PHP framework.
You shouldn't put your node.js code in any web accessible folder (like www), as this is server code and it shouldn't be accessible from the web.
Your best bet is to just make another directory to host your node.js application which isn't in www or any other web accessible directory.
There must be some file named js, javascript, or script somewhere in your root folder. There you should put this file.
Our main website uses symfony 1, and by the time I started working on the code it seems impossible to upgrade (too much custom code from previous developer). Now we are adding a large addition to what the company offers. Instead of using a really old framework I wanted to use CodeIgniter, also since I'm very familiar with it. My real question:
What is a proper way of setting up a website to use multiple frameworks. The new features will be separate from the original website, but it will still need a few tables of the database.
I was going to have apache handle where the root directory was depending on the url and just do everything normally. The main website is example.com and the new feature will be abc.example.com
I'm really looking for people who have done this and some tips and warning they had.
PHP will run the framework based on which directory is loaded on the server. For instance, on most apache servers the root directory for example.com would be /www. Which means all of the code for Symphony would be in /www/*.
When you setup the path of your subdomain, just put it outside of the /www folder. Then, when you go to abc.example.com apache won't try to load the original site along with the Symphony framework.
I think it will be fine for both frameworks to share the same database tables. I'm not entirely sure how you plan for these two applications to work, but as long as you don't change the column names and types you should be okay.
If you don't want the applications to share the data in the original table, then look into using mysqldump or something of the like to copy the data over to a new table.
I built a PHP application using Drupal and I want it to run under the same domain where Rails is running. So for example I have mysite.com running on Ruby on Rails, I would like to install and run Drupal in mysite.com/my_drupal_application.
I tried creating a subfolder inside rails , on the same level as apps and models directories but that did not worked. I tried moving creating a subfolder in the public directory too but it didnt worked either.
Maybe rails is confusing the url to be calling a controller? So what else should i do then?
Thanks a lot!
Both Drupal and rails have their own routing logic. Drupal stores it in both the database and the hook_menu, rails has it defined in the router.rb. They will conflict at some point.
So, the advice is to run your Drupal app on either a different subdomain, defined in a virtual-host. Alternatively you can define vhosts that define urls where your rails and Drupal app run. You should run them next to one another, and never inside one another.
Coming from a .net background so bear with me!
Does php have anything like a web.config or a global.asax file or is it simply dropping the application in the file system and boom it is running on the web server? (obviously dropping the files mapped in apache for the domain etc).
Specifically thinking of setting up wordpress.
PHP is a parser itself. It is not a framework. In ASP.NET, it is a Framework and thus it has its own config files.
As for PHP, we have php.ini - the PHP configuration that sets how PHP behaves and so on.
However for application level, you can create your own configuration file. Normally if you use a PHP framework, they will have an application level configuration file (eg. "config.php") which will decide how the framework will work and so on.
Wordpress installation is quite simple.
Just drop the files ;-)
Of course, you'll need to have created the database (and db user), set up the Apache's VirtualHost, and you'll have to configure the application itself...
... But there is no notion of "application server" in PHP+Apache.
About wordpress, there should be some file explaining how to install, btw ; but it's not harder than dropping the files, maybe creating the configuration one, and a couple of "next" screens ;-)