开发者

PHP/mysql application creation process

开发者 https://www.devze.com 2022-12-19 05:52 出处:网络
I am trying to figure out how one would start the setu开发者_高级运维p of a small CMS. I have the groundwork built, but the step of creating the database tables in mysql, should this all be done at o

I am trying to figure out how one would start the setu开发者_高级运维p of a small CMS.

I have the groundwork built, but the step of creating the database tables in mysql, should this all be done at once in a install.php file? Is there a preferred method for creating many tables at once, even if I don't need to insert data into them at this time?


You can

  • Import the schema file to your database prior to deploying the application

  • You can have a script that creates the schema

  • You can have a script that makes any changes to the current schema (for upgrades)

For a small CMS, I'd just keep the SQL in a schema file and import it when I need it.

You could also do a database copy from your dev -> live system. So you make the changes in the dev database as you need them and then push them to the live database. Something like SQLCompare for SQL Server works well.

Wordpress does the install.php route, where you have to enter your credentials and such for the target database and it then pushes the changes to it.


If you're going to be distributing your application for 3rd parties to install on their own servers, a very common approach is to provide (as you said) a simple install.php file. If your application is more complicated, often times an installation directory will come packaged. The user installing the application opens this in a browser, where your script typically does a few things:

  • Check PHP installation - verify (using function_exists()) all the required functions (and thus libraries) are installed and available. Alert the user of anything missing.
  • Allow the user to enter their configuration parameters - application specific settings required. Typically database hostname, username & password.
  • Test database connection - if successful, load initial tables. Commonly you keep your base schema file stored as a SQL file, so the application pushes this through the native mysql client, or issues the individual SQL commands directly.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号