小编myn*_*utt的帖子

将php库导入Cakephp

我是Cakephp的新手.我想在我的Cakephp网络应用程序中使用外部php库..所以目录结构就像那样

我从这里下载了这个dropbox php库..所以你也可以在这里看到目录结构 https://github.com/BenTheDesigner/Dropbox

    mydropboxfolder/examples/accountinfo.php
Run Code Online (Sandbox Code Playgroud)

目前我只是想先尝试这些例子,因为当我在没有cakephp的情况下运行它们时这些工作正常

所以我所做的是将整个文件夹(mydropboxfolder)复制到我的app/Lib中

我将文件accountinfo.php更改为类,所以我添加了一些像这样的代码

  class  accountinfo{

public static function getccountinfo(){
  //whole accountinfo class code here
     }
Run Code Online (Sandbox Code Playgroud)

然后在Controller中我正在调用此文件

  function dropbox()
      App::uses('accountinfo', 'mydropboxfolder/examples');
    accountinfo::account_info();  
Run Code Online (Sandbox Code Playgroud)

但我得到这些错误

错误:require_once()[http://php.net/function.require'>function.require]:无法打开所需的'../Dropbox/OAuth/Storage/Encrypter.php'(include_path ='C:\ xampp\htdocs\cakephp\lib;.; C:\ xampp\php\PEAR')
文件:C:\ xampp\htdocs\cakephp\app\Lib\dropbox\examples\bootstrap.php
行:26

我不知道我做错了..是有些文件没有加载或其他东西..提前感谢

cakephp cakephp-2.0 cakephp-2.1

2
推荐指数
1
解决办法
7709
查看次数

cakephp将数据导出到excel或Csv文件中

我正在使用Cakephp 2.x ..我正在使用解决方案将数据导出到Excel工作表..问题是我不知道如何添加列名称或标题,然后将数据放在列下..

例如,这是我目前正在做的事情

$this->CSV->addRow(array_keys($line));
 foreach ($Contacts as $contact)
 {
      $line = $contact['Contact'];

       $this->CSV->addRow($line);
 }

$filename='orders';
 echo  $this->CSV->render($filename); 
Run Code Online (Sandbox Code Playgroud)

我想要制作我的Excel工作表是这样的,就像我在我的视图页面中所做的那样.

      <table>

<tr>

    <th>Title</th>
    <th>Body</th>
    <th>Actions</th>
</tr>
<?php foreach($contacts as $contacts){?>
    <tr>

        <td> hello</td>
        <td> hello</td>
        <td> hello</td>
     </tr>
 }
    ?>
Run Code Online (Sandbox Code Playgroud)

php cakephp export-to-excel cakephp-2.0 cakephp-2.1

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

cakephp ×2

cakephp-2.0 ×2

cakephp-2.1 ×2

export-to-excel ×1

php ×1