0

コードベース (php) がサーバーの /var/tmp/myapp/ ディレクトリにあるシステムを開発していますが、ブラウザからアクセスできる UI を使用してアクセス/対話する必要があります。これは可能ですか、またはどのようにコードを public_html ディレクトリ内に移動する必要がありますか - 私が本当に望んでいないこと。

提案をありがとう。

4

1 に答える 1

0

@MichaelBerkowski の助けのおかげで、これは質問に対する解決策を含む簡単なテスト済みのスニペットです。

<?php
/**
 * Include code base from outside public_html to be accessible to scripts
 * that are accessible via web browser
 */ 

// defines the path of the codebase
define("APPLICATION_PATH", realpath('/usr/apps/myapp/controllers/'));

// defines the working directory of the, i.e., index.php file
define("CURRENT_PATH", getcwd());

// create the paths array
$paths = array(APPLICATION_PATH, CURRENT_PATH);

// set the include path configuration option for the duration of the script
set_include_path(implode($paths, PATH_SEPARATOR));

// include a script file located in the realpath
include('ReporterClass.php'); // located in /usr/apps/myapp/

// instantiate the class
$report = new Reporter();

// test output
echo "<h3>".$report->showReport("Sample Report")."</h3>";
?>
于 2014-05-31T23:00:05.517 に答える