This might seem to be a silly question but I was wondering if there any programs out there that would scan over a directory of PHP scripts and generate a report that states exactly what databases and tables are queried in each particular script?
Our database type is MySQL. Thanks for your help.
You might try something like PHP Code Sniffer. It's a static analysis tool that can search through PHP code for certain rules. You may have to end up writing your own sniffing rules, but it might be somewhere you could start. I've used it to check PHP version updates and it's worked pretty well. Just search for 'php code sniffer custom standards' and you can find some useful stuff to help get started.
Related
I have not found a library that handles exporting data and structure to SQL. - there are a number of snippets and so on for data only. Exporting structure seems quite a bit more complicated. It must be able to do this without command-line access.
Many of the descriptions I've found online are quite old, so perhaps MySQL has new features that handle this? Or perhaps there are now libraries which do this? (Or perhaps PHPMyAdmin has a self-contained class or set of functions I could hijack?)
You could try this: Sypex Dumper
I used it for a long time with Joomla on XAMPP, very light weight and functional.
You can simply use it standalone or integrate to your application.
This class suited my needs
https://github.com/2createStudio/shuttle-export
You can see several examples in the documentation. The only flaw is that this class don't have the force download option (it always generate the file in disk). I was willing to make a pull request, but there's one push request dating from 6 months ago and the mantainer didn't give a dam.
As in JSP we give "WAR" file to clients and it contains .class files and other configuration files but not the source code, is there any way, in PHP, to deliver the project (website) to client without giving them source code.
Facebook created a project called HipHop php, a php compiler.
See this post:
Can you "compile" PHP code?
Short answer, not really.
I mean you can compile php into a single .phar file however anyone with moderate php knowledge can get the code from that.
There are also solutions http://www.ioncube.com/ though I don't know how easily someone can get the code from it however I would strongly advise against any solution like this as they generally require the user of this "compiled" code to you their proprietary software to run it.
I've always used MySQL with PHP and on my site I added a chat system that uses MySQL which as you would know is VERY database heavy so I think I'm going to switch it over to XML files for each user just for the chat system to take all the load off of the DB.
I have never used XML with PHP before so I was looking for information, and found that the queries are pretty similar to MySQL.
Here are my questions:
Is it the client writing to the file or the server writing to the file?
Do I have to chmod them as 777?
Do I also have to chmod the XML file as 777?
If I do have to set the permissions to 777, does that drastically decrease security and is there any way to tighten that up?
Does anyone have any tutorials they would recommend me to as well? Most of the stuff I found is from 2003 - 2005. Don't know how much has changed in it.
Hope it's cool I ask this question here.
Thanks a bunch
-Sal
First off, it seems like a very bad idea to do something that is very database intensive in xml, it is going to be a lot more intensive that way.
To answer your question; It is always the server writing to the server filesystem. you only need to provide write access to the user running apache (and consequently php).
I suggest you stick with mysql for chat but look into DOMDocument to learn more about xml
I've been a research programmer (MATLAB) for most of my programming career, writing things for only myself that can be run on my own computer. Now, I'd like to be able to have people submit a comma-delimited text file and get processed text files in return without having to use my computer directly (only 1 MATLAB installment).
I'm thinking perhaps this can be done on my web server (XAMPP) over LAN and some programming language script that can be run on my server. This is what I'm thinking:
have people create comma-delimited text files.
have them go to a site I created on my localhost and submit it via a webpage forum.
have the uploaded file processed in PHP (small files, < 100KB). This involves looking up a MySQL database as well.
have people download the processed files somehow.
Is this a sound system? By "sound" I mean, if you, the expert, wanted to set up this system, would this be the steps and tools you would use? I've been learning PHP lately, and it seems like I could do this using PHP, but I'm not sure if this is the right tool for the task. The whole thing seems ... a bit on-the-fly, as in you upload the file, and things are done in PHP memory (from what I've read) instead of the file being stored on my server and the server running a script using that file (is there a difference?!). I would be greatly thankful if you guys could chime in and give me some pointers on how to do this properly (general ideas, not asking for codes).
PHP is most definitely a good tool for something like this. As meteorainer mentioned, PHP offers a pretty simple solution for most of what you need to do, and is much less complicated (in my opinion) than Java or .NET. I also believe it to be much easier to get started with.
As far as pointers go, a lot of what you need to accomplish can be found in the PHP manual itself, along with code samples. For example:
File uploads:
http://php.net/manual/en/features.file-upload.php
CSV Processing:
http://php.net/manual/en/function.fgetcsv.php
or, the method meteorainer mentioned
http://us3.php.net/manual/en/function.explode.php
MySQL Databases:
http://us3.php.net/manual/en/book.mysql.php
http://us3.php.net/manual/en/function.mysql-connect.php
Creating new files:
http://php.net/manual/en/function.fwrite.php
As far as whether or not this is a sound system, that all really depends on what this is going to be used for. I may be wrong, but it sounds like you just need a simple application for a very specific use. If this is the case, I would say it sounds just fine. You can always expand upon it later on if you choose to do so. Adding more security measures, more robust output, things like that. Either way, at the very least, your PHP implementation sounds like pretty good starting point to me.
Ya php can definitely do what you are looking for. You'll be using functions like:
$variablesArray = explode(file_get_contents('uploadedfile.csv'));
To bust open the CVS into a useful array and do some storage/math to that. PHP is definitely your bag.
You have other options, like java and asp, but imo java is far too complicated for what you get out of it, and asp requires a .net license and again, grants nothing over FREE php.
I was just wondering how I use Ant to build my web applications that I have written in PHP? I've googled around a bit and I have seen that it is possible but there are not any examples of the basic idea or any advanced use for them. Can any of you help me out?
Thanks!
This is definitely possible. If you are looking for a pure php solution phing might be what you want. Also note that there's usually no reasons to build PHP scripts. They should 'just work'.
While Ant itself is written in java, you can use it to build any kind of applications you want. Here's a basic tutorial and a full manual. Beyond that, you need to clarify what is it you want to do to get a more precise answer here.
Update (based on question clarifications):
Copying / moving files / folders is easy via Ant. Look through the "Hello World" tutorial I've linked above and Familiarize yourself with FileSet concept and Copy, Mkdir and Move tasks to get started. Here's another tutorial that shows how to set up a basic build (ignore java-specific stuff like javac/war).
Making changes to the database is an entirely different subject. If you have 'alter' scripts ready, you can use Ant's Exec task to invoke your DB's command-line client to run those scripts (though I probably wouldn't do it in production). If you want to use Ant to track those changes, then you're looking at the wrong tool. Liquibase can be used to do that and it seems to be getting a lot of traction lately. It's quite like Ant in the sense that it's written in Java but can be used in any environment. I'm no PHP expert so I wouldn't know if there's something more PHP-geared available.
We use ant to 'build' php apps. At it's most basic, the ant script just copies the file into the folder on the testing webserver (localhost in my case).
Why do this? well there's not a great deal of point to it, but it is a handy way to avoid putting .svn files into the webserver. If you want to change the location of the webserver you can just build to the new location. You can also do different things according to whether you're on Linux or Windows for example, but I've never used that side of it.
Having tried Phing, Ant and Gradle, I would strongly recommend gradle. Here is a bit of description Choosing tools for PHP application automation