Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Is there any PHP refactoring tool that would transform a huge noodle code to a proper function based one?
No, you can't do that automatized. Static analysis may reformat your code, eliminate bad practices or inform you about security vulnerabilities, but it can't turn your code into nice and clean OOP.
2019+ answer
Nowadays you can use a tool called Rector (I'm author of).
It uses nikic/php-parser, static analysis and node based rules. That means you can e.g. rename every case of function strlen to Nette\Utils\Strings::length().
Or basically anything you want to. Many rules are supported from in the core code (see Rector on Github), e.g. upgrade from PHP 5.2 throughout to 7.4.
But it can be configured to do what you want. It will take some thinking to determine how to detect what should be extracted and what not. If you can put the transformation into words as a human, it's possible to put that into PHP code so it will do everywhere in your code for you.
Zend Studio (for Eclipse) has support for refactoring code - it allows you to select a piece of code and extract functions/methods. For example:
It also allows for renaming of variables to further clean up your code. While this is not a fully automated solution, it will significantly help you clean up the mess. Hope this helps.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
There are many code protection libraries in php, however they require installation of additional php modules, which I can not afford because the application will be running on servers I do not own. So I thought I could make my own.
What I want to do:
$source = file_get_contents("encryptedPhpFile.php");
$source = decrypt($source, "mySecretKey");
//$source now contains decrypted source code which needs to be included
//I cant use eval($source); because that code also contains
//html/css/opening and closing php tags ... which eval() does
//not know how to render
//I cant write the source into temporary file and then include
//that file because as soon as I write decrypted source to a disk,
//it is exposed and it can be copyed
What can I do? Any suggestions?
These libraries are modules for a reason. You will not be able to fully simulate them in "code space". Your attempts will be clumsy (not your fault) and make your codebase far less pleasing/maintainable.
You should instead focus your efforts on obtaining permission to install them, migrating to a host that lets you control your server to a useful degree, or getting your own server up and running.
Again and again.
We cannot protect PHP source code. PHP was not meant to be 'protected'. Even compiling code to binary is prone to reverse engineering. In your example, when you decrypt source with secret key (how secret - there he is) you do what? Eval it? Replace eval with echo.
Write license & do legal job with lawyer. Organize business model so your customers would want to pay you so they could get updates & support.
Regarding code protection libraries (paid ones): there are free online services that automatically decode them for you...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to learn OOP PHP, and I think I need to know all predefined classes of PHP. However I cannot find any website that has list of them. On php.net i only find functions and there are examples of doing it oop or procedural way. Does anybody know where should I find those classes? Big thanks for replies
There is a function for that: http://php.net/manual/en/function.get-declared-classes.php
Note that this doesn't output interfaces, but there is also a function for that: http://php.net/manual/en/function.get-declared-interfaces.php
Remember that this will give you all classes of extensions that are currently installed, as only these are available. It will not include classes or interfaces that are available in extensions that are not installed.
However, learning OOP is independent from knowing all existing classes. If you want to do something concrete, like accessing the file system, I'd think it appropriate to then read about file system classes and their OOP interface, but it would be useless to read about the Memcache class if you don't want to use Memcache. Most of the time in OOP you create your own classes and program the business logic of the application - you will encounter built-in classes very rarely, because usually you'd add a wrapping or isolating layer around their results pretty soon, and then pass these (your own) objects around.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I want to implement a decision tree (machine learning) algorithm in PHP. I've searched far and wide on Google and can find nothing in PHP.
Does anyone know a tutorial or function in PHP for implementing a descision tree?
Are you looking specifically for Php code or any other languages are ok ?
You can start from the source code of original decision tree algorithm-C4.5.It is public but has some restrictions I think. http://www.rulequest.com/Personal/
Here is a good tutorial that you may want to refer : http://www2.cs.uregina.ca/~dbd/cs831/notes/ml/dtrees/c4.5/tutorial.html
Weka implementations for decision tree J48 is available at : https://svn.scms.waikato.ac.nz/svn/weka/trunk/weka/src/main/java/weka/classifiers/trees/J48.java
If you are familiar with Python Orange C4.5 source code is available at : http://orange.biolab.si/
I do not work with PhP so I am not aware of any implementations in it. But all above implementations(C++,Java,or Python) are worthwhile too look.
Albeit being commented and documented in Japanese, this seems to be pretty close to what you're looking for: https://github.com/kokukuma/php-decision-tree
This is the most recent implementation of the C4.5 Algorithm in PHP on GitHub as of 2019: PHP-C45.
I'm currently using it and it's very efficient too.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm in the process of generating API docs for an in-house web app that's undergoing some expansion. It's a DHTML project, with a mix of both some OO and mostly procedural PHP, and purely procedural Javascript. At the moment, it's pretty much all documented for the appropriate doc generators (phpdocumentor and jsdoc), but the two were never "connected". I could go through and add manual link statements to the doc blocks, but managing all those links (like "../jsdoc/filename.html#function) is a real pain.
Any suggestions for documentation generators that handle both PHP and JavaScript, and allow something like #see functionName between languages?
If worst comes to worst, I can hack together a script to rewrite LINK URLs from some magic syntax (i.e. js: and php:), but I'd really rather have something that will allow a unified tree view of everything.
Thanks,
Jason
After looking at a number of options, I wrote a PHP script that parses JS files, pulls out the doc blocks and function definitions, and then writes it to a file that phpdoc can process. It just needs one line added to phpDocumentor.ini so it will parse .js files.
The blog post talking about it is at:
http://blog.jasonantman.com/2010/08/documentation-generation-for-web-apps-php-and-javascript/
And the script is at:
http://svn.jasonantman.com/misc-scripts/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I know (PHP's) var_dump is supposed to be "human readable" and all, but analyzing large objects is just a pain in the neck. I am struggling to make sense of a few of the large objects that are being passed around in a script that we are running. (I know that using xdebug with and IDE is a good idea, but I have not been able to get xdebug to run on this project for some reason - several days lost, ugh).
Any ideas on how I can easily digest the contents of a really big var_dump? Any ideas are welcome... Although I am hoping that there is something similar to Thomas Frank's JSON tool (where you just put some code in and it gives a nice graphical representation).
I'd just use dBug.
You could take a look at FirePHP. It enables you to write information to the firebug-console. If you write an array or object to the log and hover with your mouse over it, you get a nice presentation of the contents of that array. Here is a screenshot of a simple example.
I made a var_dump alternative you should like:
http://raveren.github.io/kint/
Screenshot demonstrating content-aware features:
(source: github.io)
Interesting question. I'd make my own var_dump() equivalent based on some recursive function. With some parameters (such as nesting level, certain element name, etc) to pass it could be quite useful I think.