I need to extract some static data from PHP files in ruby. I’ve looked around but I couldn’t find any practical tools.
Does anyone know of a Ruby lib that would enable me to get the AST from a PHP source file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you have php on your server, you could use PHP-Parser to parse your php files, then output the parsed result (in an easy to read format such as json) for ruby to then read and use.
Although if you can get away with using a regex solution (eg if you just need to grab some constant variable values), it would probably be okay to do that. It is hard to know depending on how complex your input php files are and how much data you need to extract.