小编Kri*_*ofe的帖子

Laravel日志级别,有何不同?

我可以在Laravel 5.4中看到很少的日志选项,例如

Log::emergency($message);
Log::alert($message);
Log::critical($message);
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);
Run Code Online (Sandbox Code Playgroud)

我可以在更改日志级别app.php'log_level' => env('APP_LOG_LEVEL', 'debug'),任何种类的水平我想要的.

但我想知道,有什么不同?当critical, alert, emergency选择其中一个时,什么样的日志已被破坏?

php logging laravel laravel-5

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

URL命中错误的控制器LARAVEL

在route.php中,我定义了一个到控制器的路由,上面有2个令牌.

Route::get('/{category}/{slug}', 'projectController@detail');
Run Code Online (Sandbox Code Playgroud)

一切正常,直到调用一个具有相同结构但与必须被下面所示的路由捕获的URL无关的URL.

因此,当我有例如"/admin/tags",下面的控制器被触发,因为它具有相同的结构"/{category}/{slug}",当然它给我一个错误,因为它没有找到变量.

所以现在我修复了在底部移动该路线的问题,但我相信我必须提前做一些事情以防止这种行为,因为如果我有多个具有不同令牌的路线,那么每次都会触发一切并且会出现混乱.

那么,在这些情况下它应该做什么呢?

PS我是Laravel的超级初学者

php controller routes laravel

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

读取流中的实时整个输出

注:这篇文章有与此不同岗位,其接受的答案每次只读取每一行。

我必须在服务器端对 3D 模型进行切片以进行 3D 打印,该过程将花费一些时间。所以我要给用户展示进程,我用redis来存储进程。我想每 0.5 秒刷新一次进程。比如sleep 0.5秒,读取pip中的所有内容,每次都处理。

现在我已经尝试了以下两个,第一个将保持直到完成。第二种使用while不是妥当,它会一直写redis会导致客户端读取进程请求一直拖到最后。

我试过这两个:

第一个将保持直到命令完成。

$descriptorspec = array(
    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("pipe", "w")    //here curaengine log all the info into stderror
);
$command = './CuraEngine slice -p -j ' . $fdmprinterpath . ' -j ' . $configpath . ' -o ' . $gcodepath . ' -l ' . $tempstlpath;
$cwd = '/usr/local/curaengine';
$process = proc_open($command, $descriptorspec, $pipes, $cwd);
if(is_resource($process))
{
    print stream_get_contents($pipes[1]);  //This will …
Run Code Online (Sandbox Code Playgroud)

php real-time pipe process stream

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

setTimeout停止工作

我有一个页面,我希望始终保持文件中的值.

基本上我有一个脚本保存一些数据供我在网站上以txt文件显示,然后我想在网上显示这些数据.文本文件中的数据每20秒左右更新一次.

它的工作效果很好,比如3分钟左右,然后页面就停止了.任何想法为什么会这样?

function updatepot(elementid) {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById(elementid).innerHTML = this.responseText;
            }
        };
        xmlhttp.open("GET", "../readData.php?q=" + elementid, true);
        xmlhttp.send();

}

function updatePots()
{
       updatepot("pot0");
}
function keeprunning()
{
    setTimeout(updatePots, 1000);
    keeprunning();
}


<?php    
// get the q parameter from URL
$file = $_REQUEST["q"] . ".txt";
$myfile = fopen("potData/".$file, "r") or die("Unable to open file!");
$myData;
while(!feof($myfile)) {
  $myData =  $myData . fgets($myfile);
}
fclose($myfile); …
Run Code Online (Sandbox Code Playgroud)

html javascript php settimeout

5
推荐指数
2
解决办法
1080
查看次数

如何在 PHP 中计算目录中 .txt 文件的数量?

我正在开发一个 IMDB 风格的网站,我需要动态查找电影的评论量。评论存储在名为的文件夹中,/moviefiles/moviename/review[*].txt其中[*]是评论的编号。基本上我需要以整数形式返回该目录中存在多少个文件。我该怎么做呢?

谢谢。

php file file-handling

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

Swift3如何为UISegmentedControl设置默认文本颜色?

我想为UISegmentedControl的文本和背景设置颜色。因此,我要设置四种颜色,即文本和背景的默认和选定颜色。

我可以使用tintColorbackgroundColor设置背景。但是如何设置默认的文本颜色,而不是色调颜色?

注意:这是swift3而非较旧的语言。我的ios的初学者,我刚刚从swift3开始,没有前者语言的经验。

任何帮助将不胜感激。

iphone uisegmentedcontrol ios10 xcode8 swift3.0.2

5
推荐指数
4
解决办法
3986
查看次数

如何只制作一个子视图?

我知道有一个samilar问题只有一个VIEW横向模式,在我问这个之前我已经仔细考虑过了.

我的应用程序中有一个名为webview的WKWebview,webview有一个名为player的子视图.我使用webview加载网页,播放器播放视频.

默认情况下,播放器在webview的右下角进行压缩,我想在单击播放器的展开按钮时将播放器扩展为横向.

因为webview和播放器在WebViewController.swift中是defind,这就是说在同一个控制器中.我怎样才能让玩家子视图成为风景?

xcode subview uiviewcontroller uiview swift3

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

如何在 Javascript 中将元素 ID 作为参数或参数传递

如何从输入元素的 id 中获取元素并将其作为参数传递给 java 脚本函数。

 <html>
 <body>
 <input type="text" id="name">
 <input type="button" onclick="call(id_of_input_type_text)" value="Click 
  me">
 <script>
 var call(id_of_input_type_text) = function(){
 var x = document.getElementById(id_of_input_type_text).value;
 alert(x);
 }
 </script>
 </body>
</html>
Run Code Online (Sandbox Code Playgroud)

先生/妈妈我想使用像验证这样的单一函数并通过函数中的传递 id 获得值所以请帮助我解决这个问题

javascript

5
推荐指数
2
解决办法
4万
查看次数

如何在自定义验证规则中使用laravel的验证规则?

我有输入$data =['identifier' = 'xxxxxxxxxx'];,并希望保存encrypt($data['identifier'])到表infoid列.

我要在保存之前验证.规则unique:info, id不适用于此,因此我想编写自定义验证规则.在自定义验证规则中,我encrypt()首先使用值,然后使用unique验证规则.

我知道如何编写自定义验证规则,但如何unique在自定义验证规则中使用验证规则?

php validation input laravel

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

如何设置 blob 数据的下载文件扩展名

在我的网站视频中使用 blob 数据,下载视频时,保存的文件名是 Chrome 浏览器中带有.txt( 4671addc-3ce0-4eb6-b414-ddf3406b1fe5.txt) 扩展名的 blob 名称,而在 firefox 中是带有.mp4( 4671addc-3ce0-4eb6-b414-ddf3406b1fe5.mp4) 扩展名的 blob 名称。

如何指定下载文件扩展名和文件名。

我尝试用下面的代码设置它,但没有任何效果。

    type="video/mp4"
    filename="111.mp4"
    download="111.mp4"
Run Code Online (Sandbox Code Playgroud)

这是我现在使用的示例代码。

<video 
    width="300px"
    id="video"
    type="video/mp4"
    filename="111.mp4"
    download="111.mp4"
    controls=""
    src="blob:http://localhost/4671addc-3ce0-4eb6-b414-ddf3406b1fe5">
</video>
Run Code Online (Sandbox Code Playgroud)

html javascript video google-chrome blob

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