小编Rah*_*eel的帖子

Apache 未在 docker 上自动运行 compose up

文件

FROM phusion/baseimage:0.9.16
MAINTAINER Raheel <raheelwp@gmail.com>

# Apache
RUN apt-get update
RUN apt-get -y install apache2

# PHP
RUN apt-get -y install python-software-properties
RUN add-apt-repository ppa:ondrej/php
RUN apt-get update
RUN apt-get -y install php7.0
RUN apt-get -y install libapache2-mod-php7.0 php7.0-curl php7.0-json

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
Run Code Online (Sandbox Code Playgroud)

docker-composer.yaml

version: '2'
services:
  frontend:
    build: ./frontend
    ports:
     - "80:80"
    volumes:
     - ./frontend:/var/www/html/frontend
Run Code Online (Sandbox Code Playgroud)

我正在尝试在 docker 中运行我的 Laravel 应用程序。我面临两个问题

1 - 当我运行 docker-compose up 时,容器内的 apache 服务器不会自动启动。每次我必须登录容器并执行service apache2 start. 根据我的搜索,我发现我在 Dockerfile 中写的 CMD 命令是我们如何启动 …

php apache docker dockerfile docker-compose

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

使用www-data用户运行Laravel命令

我在Laravel 5.1中发出了一个命令,它应该从文件系统中删除一些目录.

handle()命令类的方法中,我做了shell_exec("whoami") ,它返回raheel.但是,用户raheel对指定的目录没有权限.我想以apache www-data用户身份运行此命令.

我怎样才能在Laravel中实现这一点?

谢谢

php linux laravel laravel-5.1

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

Atom PHP lint无法运行Windows 10

我有新的Atom安装.安装linter包然后linter-php.

在config.cson文件中我有以下内容

"*":
  "exception-reporting":
    userId: "c545e431-a953-b271-c123-c021c950953b"
  welcome:
    showOnStartup: false
  core: {}
  editor:
    invisibles: {}
    tabLength: 4
  linter: {}
  "linter-php":
    executablePath: "C:/php/"
Run Code Online (Sandbox Code Playgroud)

我从http://windows.php.net/downloads/releases/php-5.6.16-Win32-VC11-x86.zip里面下载了PHP zip 并将其解压缩C:/php

任何人都可以帮我解决这个问题.我找不到任何我想念的东西.

更新

这是我得到的错误

Error: 'C:/php/' is not recognized as an internal or external command,
operable program or batch file.
    at parameters.exit (C:\Users\Raheel\.atom\packages\linter-php\node_modules\atom-linter\lib\helpers.js:70:20)
    at triggerExitCallback (C:\Users\Raheel\AppData\Local\atom\app-1.2.4\resources\app.asar\src\buffered-process.js:213:47)
    at ChildProcess.<anonymous> (C:\Users\Raheel\AppData\Local\atom\app-1.2.4\resources\app.asar\src\buffered-process.js:235:18)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

php atom-editor

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

无法在 React PHP 中进行非阻塞 I/O

我试图在数据库中插入一条记录到反应套接字服务器。我不知道如何以非阻塞方式进行操作

$loop = Factory::create();

$server = new Server('127.0.0.1:4040', $loop);
$database = new Database();

$server->on('connection', function(ConnectionInterface $conn)  use ($database) {
    $conn->write('Welcome, you can start writing your notes now...');

    $conn->on('data', function($data) use ($conn, $database) {
        $database->write($data);
        $conn->write('I am supposed to execute before database write');
    });
});

$loop->run();
Run Code Online (Sandbox Code Playgroud)

write数据库中的方法在sleep(10)执行sql语句之前有几秒钟的时间。所以我期待I am supposed to..应该立即打印下一条消息。

我的期望是,当有 I/O 操作时,该操作将被移动到事件表并且不会阻塞调用堆栈。根据事件循环和非阻塞的定义。

如何以非阻塞方式执行相同的操作。

谢谢

php nonblocking event-loop reactphp

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

addng ReadAllFromText 转换时管道失败

我正在尝试在 Apache Beam 中运行一个非常简单的程序来尝试它是如何工作的。

import apache_beam as beam


class Split(beam.DoFn):
    def process(self, element):
        return element


with beam.Pipeline() as p:
    rows = (p | beam.io.ReadAllFromText(
        "input.csv") | beam.ParDo(Split()))
Run Code Online (Sandbox Code Playgroud)

运行此程序时,我收到以下错误

.... some more stack....
 File "/home/raheel/code/beam-practice/lib/python2.7/site-packages/apache_beam/transforms/util.py", line 565, in expand
    windowing_saved = pcoll.windowing
  File "/home/raheel/code/beam-practice/lib/python2.7/site-packages/apache_beam/pvalue.py", line 137, in windowing
    self.producer.inputs)
  File "/home/raheel/code/beam-practice/lib/python2.7/site-packages/apache_beam/transforms/ptransform.py", line 464, in get_windowing
    return inputs[0].windowing
  File "/home/raheel/code/beam-practice/lib/python2.7/site-packages/apache_beam/pvalue.py", line 137, in windowing
    self.producer.inputs)
  File "/home/raheel/code/beam-practice/lib/python2.7/site-packages/apache_beam/transforms/ptransform.py", line 464, in get_windowing
    return inputs[0].windowing
AttributeError: 'PBegin' object has no attribute 'windowing'
Run Code Online (Sandbox Code Playgroud)

知道这里出了什么问题吗?

谢谢

apache-beam apache-beam-io

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

如何在子类中调用基类的构造函数

下面是我的基类,即数据库方法.

// Constructor
public function __construct($argHost, $argUsername, $argPassword, $argDatabase)
{
    $this->_host = $argHost;
    $this->_username = $argUsername;
    $this->_password = $argPassword;
    $this->_database = $argDatabase;
}

// Connect to the database
public function Connect()
{
    if (!$this->Is_Connected()) {
        $this->_connection = mysqli_connect($this->_host,$this->_username,$this->_password,$this->_database);    
    } else {
        return $this->_connection;
    }

}
// Run query
public function Run($query)
{
    if ($this->result = mysqli_query($this->_connection,$query)) {
        return $this->result;
    } else {
        die("Couldn't perform the request");
    }
}
Run Code Online (Sandbox Code Playgroud)

我的孩子课是下面的分类方法

class Categories extends Database
{    
    public $category_id = '';
    public $category_name …
Run Code Online (Sandbox Code Playgroud)

php oop

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

如何使用AngularJS构建CodeIgniter应用程序?

我想创建一个应用程序,其中后端由CodeIgniter驱动,前端由AnuglarJS驱动。

到目前为止,我有一个想法,我们可以使用Angular JS $ http服务从Codeigniter获取数据。但是我很困惑如何对待观点。

例如:

我的默认控制器是“登录”。我在controllers文件夹中创建了一个login.php文件,并以index方法呈现了登录表单的视图。现在,如果仅使用CodeIgniter流,我将仅将表单操作放置到登录控制器的doLogin()方法中,然后在该表单中将用户重定向到他的仪表板。

我们如何在AngularJS中实现这一点,以便当用户填写表单并单击“登录”按钮时,页面不会刷新并且显示仪表板?

codeigniter angularjs

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

Laravel中如何使用statement方法指定数据库连接

我正在 Laravel 使用方法运行原始查询DB::statement()。该语句需要从我的辅助数据库中获取数据。

我想知道是否有任何干净的方法来指定此方法的数据库连接,而不是在所有字段之前使用数据库名称前缀。

laravel

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

Pandas df.apply不会修改DataFrame

我刚开始做大熊猫,请原谅这是不是很蠢.

我正在尝试将一个函数应用于列,但它不起作用,我也没有看到任何错误.

 capitalizer = lambda x: x.upper()
    for df in pd.read_csv(downloaded_file, chunksize=2, compression='gzip', low_memory=False):
        df['level1'].apply(capitalizer)
        print df
        exit(1)
Run Code Online (Sandbox Code Playgroud)

此打印显示的level1列值与原始csv不相同upper.我错过了什么吗?

谢谢

python apply dataframe pandas

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

覆盖材质 UI 扩展面板摘要

expansionPanelSummary: {
        content: {
            "& > :last-child": {
                paddingRight: 0
            }
        },
        expandIcon: {
            top: "80%"
        }
    }
Run Code Online (Sandbox Code Playgroud)

我正在尝试覆盖 Material UI 扩展面板组件的样式但无法获得结果

<ExpansionPanelSummary
                    expandIcon={<ExpandMoreIcon color="primary" />}
                    classes={{ content: classes.expansionPanelSummary.content, expandIcon: classes.expansionPanelSummary.expandIcon}}
                >
Run Code Online (Sandbox Code Playgroud)

我无法在主题级别覆盖它,因为此组件正在其他地方使用默认设置。

reactjs material-ui jss

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

渲染wordpress短代码而不在循环中使用the_content()

我在index.php页面中有以下代码,用于获取所有页面并更改它们.问题是我没有用来the_content()显示内容,而是使用echo $page->post_content().我现在必须在我的页面中嵌入一个联系表格7,但是当我在这里阅读不同的问题时,如果没有,则短代码将无效the_content().

我的问题是如何在这里展示联系表格.

$pages = get_pages($args); 
foreach ($pages as $page){
    // Override Homepage
    if($page->ID == 5){
        $page->post_content = file_get_contents(get_template_directory_uri().'/includes/homepage-override.php');
    }
    // Check if it is menu page
    if($page->post_parent == 169){
        $page->post_content = file_get_contents(get_template_directory_uri().'/includes/location-menu-page.php?location='.$page->post_title);
    }
    // Calling Gallery Images
    if($page->ID == 23){
        $page->post_content = file_get_contents(get_template_directory_uri().'/includes/gallery-page.php');
    }

    // Calling about page
    //if($page->ID == 7 || $page->ID == 17 || $page->ID == 29){
    if(has_post_thumbnail($page->ID)):
        $image = wp_get_attachment_image_src( get_post_thumbnail_id($page->ID), 'single-post-thumbnail' );
        $dom = new DOMDocument();
        @$dom->loadHTML($page->post_content);
        $imgs = $dom->getElementsByTagName("img"); …
Run Code Online (Sandbox Code Playgroud)

wordpress wordpress-theming wordpress-plugin

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

捕获块在节点获取中不起作用

尝试学习,JavaScript。请原谅,如果这真的是一个基本的薄我想念。

我试图运行node-fetch到错误的URL,我希望应该捕获该错误并记录我的相应消息。但是,当我通过节点运行此文件时,它给了我未捕获的错误

    const fetch = require('node-fetch');

    fetch('http://api.icnd.com/jokes/random/10')
        .then(response => {
            response.json().then((data) => {
                console.log(data)
            });
        }).
        catch(error => {
            console.log('There is some error');
        });



(node:864) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://api.icnd.com/jokes/random/10 reason: Unexpected token < in JSON at position 0
    at /Users/raheel/code/js-tutorial/node_modules/node-fetch/lib/index.js:254:32
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)
(node:864) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 node-fetch

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

自定义BaseSpider Scrapy

我想在自定义基本蜘蛛类中具有一些针对蜘蛛的通用功能。

通常,y抓的蜘蛛从scrapy.Spider类继承。

我尝试在scrapy的spiders文件夹中创建BaseSpider类,但该类无效

import scrapy


class BaseSpider(scrapy.Spider):
    def __init__(self):
        super(scrapy.Spider).__init__()

    def parse(self, response):
        pass
Run Code Online (Sandbox Code Playgroud)

这是我真正的蜘蛛

import scrapy
import BaseSpider


class EbaySpider(BaseSpider):
    name = "ebay"
    allowed_domains = ["ebay.com"]

    def __init__(self):
        self.redis = Redis(host='redis', port=6379)
    # rest of the spider code
Run Code Online (Sandbox Code Playgroud)

给出这个错误

TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)
Run Code Online (Sandbox Code Playgroud)

然后我尝试使用多重继承,使我的eBay Spider看起来像

class EbaySpider(scrapy.Spider, BaseSpider):

    name = "ebay"
    allowed_domains = ["ebay.com"]

    def __init__(self):
        self.redis = Redis(host='redis', port=6379)
    # rest of the spider code …
Run Code Online (Sandbox Code Playgroud)

python scrapy scrapy-spider

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