how can i read a file in php where the file is located on an svn repo?

狂风中的少年 提交于 2019-12-11 13:00:17

问题


I have a webpage that needs to be able to read a file for parsing and display content in a table. my html calls ajax calls my php, my php reads the file and parses and sends back the content for the table. I have tested this with the file on my local machine, but I need to be able to read the file when it is in svn. can someone point me in the right direction,

function rFile($fName)
{
    $url = "svnURL"; //my svn url
    $endName = $url.$fName.".sql";
    //echo "$endName";
    if (file_exists($endName))
    {
        //code for parsing  
    }
    else
    {
        echo " no file";

    }

}
this is what I am currently trying... and I always get "no file" so I know that this isnt right plus i think that I need to add credentials some how. I am grateful for any help and thanks in advance.


回答1:


Worked fine for me:

<?php
echo file_get_contents('https://user:pass@HOST/svn/project/trunk/htdocs/index.php');

Given that I have the APACHE WEBDAV module installed on the HOST for svn access over HTTPS .




回答2:


Have a look at the pecl extension for svn:

http://php.net/manual/en/book.svn.php

The function you probably want to use is: svn_cat



来源:https://stackoverflow.com/questions/5407846/how-can-i-read-a-file-in-php-where-the-file-is-located-on-an-svn-repo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!