简体   繁体   中英

What is best practice for saving .php files and databases

I have been wondering this for awhile so I thought I would ask. What is best practice for storing .php files and databases when testing and packaging for production when dealing with mobile apps.

This question came about because I wanted to make sure I am doing the follow example right and I really have no clue where I should have these files sitting for both testing and finished product purposes.

What I am working on: http://code.tutsplus.com/tutorials/titanium-user-authentication-part-1--mobile-3728

How you set up your PHP folder structure is up to you, of course.

First thing you need to do is to setup your webserver. Every webserver needs a "root" directory from where it can serve content. If you are running a linux based machine and an Apache server on it, this is most likely /var/www . In that folder you create folders. One for each separate app should keep that thing clean and tidy ;) In this case we are calling it my_awesome_app . The whole path would be /var/www/my_awesome_app

In that folder you are as said completely free. Some create a folder called webroot where they put all their css, images and js files in. They are then using a .htaccess to their app goes directly to that folder. If a css, js or image file is requested and it is found in the folder webroot it would be served from there. Every other request would be redirected to an index.php which then fires up the real app.

Files for the app would then lie in a folder src or app .

That was an example of how most of the big frameworks and apps work these days. It only makes sense if you have a lot of code files and other stuff to work with.

For single-file-apps like the one you are currently building in that tutorial you could easily put those files in the my_awesome_app folder and try to access them via localhost:8889/my_awesome_app/post_auth.php . That url can be totally different depending on your webserver setup.

If you do not know anything about webservers yet, I suggest you try to find out a little about it. Then to get started quickly, you could use ready-to-use stacks like XAMPP, which is available for Windows, Linux and OS X, and fire one up. You should get familiar with it first, before you actually proceed with developing, so you can find problems easier later on. ;)

If you want to deploy your app some day, you need those files lying somewhere publicly available. There are different providers for web hosting, which offer this service. You should not host the php files on your PC, because if you turn that thing off, your app goes down. ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM