我即将将共享Web主机上的laravel 4部署到子域中,我对如何操作感到困惑.我得到了一个hostpapa帐户,但对测试环境的配置和交换提供商不满意.
我创建了以下文件夹:
域/私营/安装MyApps/golfmanager
我已经在这里放置了除公用文件夹之外的所有文件和文件夹
然后我将公用文件夹的内容放入此文件夹:
域/子域/ golfmanager/httpddocs
我不知道该怎么做!我知道我需要更改bootstrap/path.php中的路径
有人可以为这个文件夹设置提供一些需要更改的指针.不想打破它!!
谢谢
我正在努力让一个集合的 groupby 工作 - 我还没有得到这个概念。
我正在为玩家从表格中提取一组结果,雄辩的集合将包含如下数据:
['player_id'=>1, 'opposition_id'=>10, 'result'=>'won', 'points'=>2],
['player_id'=>1, 'opposition_id'=>11, 'result'=>'lost', 'points'=>0],
['player_id'=>1, 'opposition_id'=>12, 'result'=>'lost', 'points'=>0],
['player_id'=>1, 'opposition_id'=>10, 'result'=>'won', 'points'=>2],
['player_id'=>1, 'opposition_id'=>11, 'result'=>'lost', 'points'=>0],
['player_id'=>1, 'opposition_id'=>10, 'result'=>'lost', 'points'=>0],
['player_id'=>1, 'opposition_id'=>12, 'result'=>'won', 'points'=>2],
Run Code Online (Sandbox Code Playgroud)
我希望能够groupBy('opposition_id')然后给我一个结果的总数,总赢,总输和总分,最终得到一个这样的集合:
['opposition_id'=>10, 'results'=>3, 'won'=>2, 'lost'=>1, 'points'=>4],
['opposition_id'=>11, 'results'=>2, 'won'=>0, 'lost'=>2, 'points'=>0],
['opposition_id'=>10, 'results'=>2, 'won'=>1, 'lost'=>1, 'points'=>2]
Run Code Online (Sandbox Code Playgroud)
我试图避免返回数据库来执行此操作,因为我已经获得了先前活动的结果。
我如何使用 Laravel 收集方法来做到这一点,到目前为止我所拥有的是:
$stats = $results->groupBy('opposition_id');
Run Code Online (Sandbox Code Playgroud)
我已经看过map()但还不明白通过解决方案工作的方法
任何人都可以指出我正确的方向。
如果需要,很高兴回到数据库,但假设我可以用我已经拥有的集合来做到这一点,而不是创建另一个查询。我在这里找到的解决方案似乎都在查询中提供了解决方案
谢谢
我正在尝试雄心勃勃并为flexigrid添加额外的搜索框...我已经深入研究了flexigrid脚本,并找到了添加搜索元素的位置.然后我添加了我自己的输入字段,如下所示:
$(g.sDiv).append("<input type='text' value='' size='30' name='fromDate' id='datepicker' class='qsbox datepicker' />");
Run Code Online (Sandbox Code Playgroud)
g.sDiv是一个在脚本前面创建的变量:
g.sDiv = document.createElement('div');
Run Code Online (Sandbox Code Playgroud)
我假设创建一个div,我可以将项目附加到它.
虽然我无法解决一些问题.如果我附加以下元素:
$(g.sDiv).append("<div id = 'customSearch'></div>");
Run Code Online (Sandbox Code Playgroud)
(它确实正确渲染)然后尝试使用以下方法附加到该div:
$('#customSearch').append("<input type='text' value='' size='30' name='fromDate' id='datepicker' class='qsbox datepicker' />");
Run Code Online (Sandbox Code Playgroud)
输入框未添加到页面中.
为什么这种方法不起作用?
此外,创建输入框后我想添加datepicker ui.如何对动态创建的项目执行此操作.我已经尝试在创建元素之后添加这行代码:
$('#datepicker').datepicker();
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
附加项目时我缺少什么,如果添加了datepicker,则在添加后将其添加到最终输入中.
好的 - 我的岩石之路进入测试(与laravel)继续...
我已经创建了一个实例和一个'存储库',我现在正在尝试测试它.但是,这样做我得到一个错误,即找不到类中的方法.对我而言意味着至少找到了这门课程.
我在config/app.php中添加了以下内容:
//custom service providers
'GolfmanagerServiceProvider'
Run Code Online (Sandbox Code Playgroud)
我的服务提供商是:
class GolfmanagerServiceProvider extends ServiceProvider {
public function register()
{
$this->app->bind(
'golfmanager\service\creator\TicketCreatorInterface',
'golfmanager\service\creator\TicketCreator'
);
}
}
Run Code Online (Sandbox Code Playgroud)
我的界面是:
interface TicketCreatorInterface {
public function createTicket($input, $book);
}
Run Code Online (Sandbox Code Playgroud)
我的'存储库' (这是正确的术语吗?):
Class TicketCreator implements TicketCreatorInterface {
protected $ticket;
public function __construct(TicketAudit $ticketAudit)
{
$this->ticket = $ticketAudit;
}
public function createTicket($input, $book) {
$counter = $input['start'];
while($counter <= $input['end']) {
$this->$ticket->create(array(
'ticketnumber'=>$counter,
'status'=>'unused',
'active'=>1
));
$this->ticket->book()->associate($book);
$counter = $counter+1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
TicketAudit是雄辩的模型
到目前为止我的测试是:
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用laravel应用程序实现blueimp jquery文件上传.https://github.com/blueimp/jQuery-File-Upload
我已经使用插件设置了正常工作和表现的表单,但是我在使用laravel创建服务器端脚本以处理上载时遇到了问题.
我已将表单操作更改为:
<form id="fileupload" action="{{ route('photos.post.upload') }}" method="POST"
enctype="multipart/form-data">
Run Code Online (Sandbox Code Playgroud)
在main.js(插件的一部分)我已将url设置为:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: '/photos/upload/'
});
Run Code Online (Sandbox Code Playgroud)
在我的路线文件中,我创建了一条路线,如下所示:
Route::any('photos/upload', [
'as'=>'photos.post.upload',
'uses' => 'PhotosController@uploadImage'
]);
Run Code Online (Sandbox Code Playgroud)
我在控制器中的功能:
public function uploadImage()
{
dd(Input::file());
return Response::json(
array(
"files" => array(
"name" => "post"
))
);
}
Run Code Online (Sandbox Code Playgroud)
此时我只想测试收到的表单数据.但是在上传时数据为空.
无论是使用Route::any()还是Route::post()却得到了一个301错误(永久移动)
检查谷歌浏览器它出现POST正在按预期用于上传,看起来像包含文件.
所以.
Input::file() 返回空任何帮助赞赏
我正在学习 php oop,浏览书籍等并尝试自己尝试。
在我的 __construct 中,我有许多具有默认值的参数(实际上所有参数都有默认值)。但是,当我尝试编写代码来创建新对象时,我遇到了语法错误问题。
例如我的构造语句有 6 个参数。我将值传递给前三个,想跳过接下来的两个并为最后一个设置一个值。我只是简单地在它们之间添加了逗号,但它会引发语法错误。
我应该用什么来代替什么都不接受默认值?
谢谢
我正在尝试提高我网站中某些代码的性能,并找到了这个分析器:https://github.com/loic-sharma/profiler
我已按照网站上的指导进行操作,并在其中一个站点控制器中包含以下内容:
public function getTest() {
$logger = new Profiler\Logger\Logger;
$profiler = new Profiler\Profiler($logger);
$profiler->startTimer('testLogging');
$data = Article::select(array(
'articles.id',
'articles.article_date',
'articles.image_link',
'articles.headline',
'articles.category'
)) ->get()
->toArray();
var_dump($data);
$profiler->endTimer('testLogging');
Log::info('Hello World!');
echo $profiler;
Run Code Online (Sandbox Code Playgroud)
在浏览器中,我得到了预期的结果,可以看到底部的探查器栏.
我有一个问题:在这个基本测试中,分析器栏,当点击时不会保持打开,所以我无法查看日志等.我不知道为什么或如何去修复.窗格打开然后立即再次关闭.
如果我删除最后的回声它可以正常工作.
我似乎无法在工具栏中看到计时器'testLogging'.
我在这里误解了一个概念吗?
如何在代码中计算特定功能并显示结果?
谢谢
还在学习如何测试php
我现在有一个工作界面(我认为) - 其中一个函数旨在创建一系列记录,我现在想要测试它.我承认我对测试知之甚少,所以问题多于知识.
所以
我的界面目前看起来像这样:
interface TicketCreatorInterface {
public function createTicket($input, $book);
}
Run Code Online (Sandbox Code Playgroud)
我的'repository'类看起来像这样:
Class TicketCreator implements TicketCreatorInterface {
protected $ticket;
public function __construct(TicketAudit $ticketAudit)
{
$this->ticket = $ticketAudit;
}
public function createTicket($input, $book) {
$counter = $input['start'];
while($counter <= $input['end']) {
$this->$ticket->create(array(
'ticketnumber'=>$counter,
'status'=>'unused',
'active'=>1
));
$this->ticket->book()->associate($book);
$counter = $counter+1;
}
return $counter;
}
Run Code Online (Sandbox Code Playgroud)
我在测试中的尝试看起来像这样:
public function testCreateCreatesTickets(TicketCreatorInterface $ticketCreator) {
//arrange
$book = Mockery::mock('Book');
//act
$response = $ticketCreator->createTicket(array('start'=>1000, 'end'=>1001), $book);
// Assert...
$this->assertEquals(true, $response);
}
Run Code Online (Sandbox Code Playgroud)
我首先尝试没有输入接口,因为我没有得到任何对象的错误.我尝试在界面上创建一个实例,但你不能这样做,所以在函数中使用了typehinting
我运行测试时得到的错误是:
Argument …Run Code Online (Sandbox Code Playgroud) 我对如何做以下事情感到有点困惑.
我有一个文章表和一个标签表,其中有多对多的连接和两者之间的数据透视表.我已经在模型中建立了关系
文章可以有多个标签.
如何根据附加到当前文章的标签轻松(?)获取文章的相关文章列表.
我试过从标签方面查询如下:
foreach($article->tags()->get() as $tag) {
$relatedArticles .= Tag::with('articles')
->where('id','=', $tag->id)
->take(6)
->get();
}
Run Code Online (Sandbox Code Playgroud)
这会产生零响应
我不确定如何从文章中查询以动态查找带有标签的文章.
因此,如果一篇文章附加了tag1和tag2,那么我想要检索所有附加了tag1或tag2的文章(理想情况是在文章日期排序).每个文章的标签都不同,可能只有一个或多个.
理想情况下,我想用一个雄辩的查询来做这个但不是必要的 - 我不知道如何在mysql中做一个起点.
任何帮助赞赏
我正在重建我的开发环境 - 没有取消wamp或xampp等,并尝试一次安装每个位.到目前为止,这变得令人头痛.我现在安装了Php,apache和mysql,现在想安装xdebug.
我已经去了xdebug网站上的向导并复制并粘贴了我的phpinfo.它工作,但没有建议我安装哪个版本,所以我一直在尝试不同的,看看哪个将工作 - 没有喜悦.
在apache错误日志中指出
Failed loading c:\wamp\php\ext\php_xdebug-2.2.0-5.4-vc9.dll
Run Code Online (Sandbox Code Playgroud)
在我的php.ini中,我有以下xdebug条目:
zend_extension = "c:\wamp\php\ext\php_xdebug-2.2.0-5.4-vc9.dll"
[xdebug]
xdebug.remote_enable = true
xdebug.profiler_enable = true
xdebug.profiler_enable_trigger = true
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.auto_trace=1
xdebug.trace_format=1
xdebug.profiler_append=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_output_dir="c:/wamp/tmp"
xdebug.trace_output_name= %t.trace
Run Code Online (Sandbox Code Playgroud)
我的php是5.4.3 x64我的apache是2.4.4 x64操作系统:Win 7 64bit
我试过xdebug版本:
php_xdebug-2.2.0-5.4-vc9.dll
php_xdebug-2.2.2-5.4-vc9-nts.dll
php_xdebug-2.2.2-5.5-vc11-x86_64.dll
Run Code Online (Sandbox Code Playgroud)
我假设它是一个兼容性选项,但由于向导类型失败,我不确定具有哪个版本.
我怎样才能使这个工作,并确保哪个是正确的版本
谢谢
laravel ×6
php ×5
laravel-4 ×2
phpunit ×2
apache ×1
append ×1
blueimp ×1
collections ×1
construct ×1
datepicker ×1
debugging ×1
eloquent ×1
installation ×1
interface ×1
javascript ×1
jquery ×1
many-to-many ×1
mocking ×1
oop ×1
profiler ×1
subdomain ×1
unit-testing ×1
xdebug ×1