php找不到名称空间库

时间:2016-05-23 11:03:36

标签: php composer-php

按照说明使用composer安装dukpt-php,编写一个简单的代码:

<?php

use DUKPT\DerivedKey;
use DUKPT\KeySerialNumber;
use DUKPT\Utility;

$ksnObj = new KeySerialNumber($ksn);
$decryptionKey = DerivedKey::calculateDataEncryptionRequestKey($ksnObj, $bdk);

但是得到错误:

Class 'DUKPT\KeySerialNumber' not found

2 个答案:

答案 0 :(得分:0)

我在PHP中看到了一些不一致(真的!?!)这种类型的语句,您可能需要使用rooted命名空间'use'语句:

/*
 DEFINITIONS

 FLEN FILE LEFT ENABLE   GPIO177
 FREN FILE RIGHT ENABLE  GPIO168
 FLC FILE LEFT C  GPIO166
 FRC FILE RIGHT C GPIO169
 FLD FILE LEFT D GPIO167
 FRD FILE RIGHT D  GPIO170

 LEH LEFT ENABLE HIGH
 LEL LEFT ENABLE LOW
 LCH LEFT C HIGH
 LCL LEFT C LOW
 LDH LEFT D HIGH
 LDL LEFT D LOW

 REH RIGHT ENABLE HIGH
 REL RIGHT ENABLE LOW
 RCH RIGHT C HIGH
 RCL RIGHT C LOW
 RDH RIGHT D HIGH
 RDL RIGHT D LOW
*/

FILE *FLEN,*FREN,*FLC,*FRC,*FLD,*FRD;

FILE *DIR_FLEN,*DIR_FREN,*DIR_FLC,*DIR_FRC,*DIR_FLD,*DIR_FRD;

//LEFT WHEEL
#define LEH() fprintf(FLEN,"1")
#define LEL() fprintf(FLEN,"0")
#define LCH() fprintf(FLC,"1")
#define LCL() fprintf(FLC,"0")
#define LDH() fprintf(FLD,"1")
#define LDL() fprintf(FLD,"0")

//RIGHT WHEEL
#define REH() fprintf(FREN,"1")
#define REL() fprintf(FREN,"0")
#define RCH() fprintf(FRC,"1")
#define RCL() fprintf(FRC,"0")
#define RDH() fprintf(FRD,"1")
#define RDL() fprintf(FRD,"0")


void MOVE_FORW(){
LEH();
LCH();
LDL();
REH();
RCH();
RDL();
}



void MOVE_BCKW(){
LEH();
LCL();
LDH();
REH();
RCL();
RDH();
}

void MOVE_RIGHT(){
LEH();
LCH();
LDL();
REH();
RCL();
RDH();
}


void MOVE_LEFT(){
LEH();
LCL();
LDH();
REH();
RCH();
RDL();
}



int main(void){

//HANDLING FILES - opening files fow writing ( overwriting )

//EXPORTING AS OUTPUT - DEFINING DIRECTION (out)

system("echo 177 > /sys/class/gpio/export");
printf("FINE\n");

DIR_FLEN=fopen("/sys/class/gpio/gpio177/direction","w+"); //GPIO 177
fprintf(DIR_FLEN,"out");
FLEN=fopen("/sys/class/gpio/gpio177/value","w+"); //GPIO 177



system("echo 168 > /sys/class/gpio/export");
DIR_FREN=fopen("/sys/class/gpio/gpio168/direction","w+"); //GPIO 168
fprintf(DIR_FREN,"out");
FREN=fopen("/sys/class/gpio/gpio168/value","w+"); //GPIO 168


system("echo 166 > /sys/class/gpio/export");
DIR_FLC=fopen("/sys/class/gpio/gpio166/direction","w+");
fprintf(DIR_FLC,"out");
FLC=fopen("/sys/class/gpio/gpio166/value","w+");


system("echo 169 > /sys/class/gpio/export");
DIR_FRC=fopen("/sys/class/gpio/gpio169/direction","w+");
fprintf(DIR_FRC,"out");
FRC=fopen("/sys/class/gpio/gpio169/value","w+");


system("echo 167 > /sys/class/gpio/export");
DIR_FLD=fopen("/sys/class/gpio/gpio167/direction","w+");
fprintf(DIR_FLD,"out");
FLD=fopen("/sys/class/gpio/gpio167/value","w+");


system("echo 170> /sys/class/gpio/export");
DIR_FRD=fopen("/sys/class/gpio/gpio170/direction","w+");
fprintf(DIR_FRD,"out");
FRD=fopen("/sys/class/gpio/gpio170/value","w+");


MOVE_FORW();

答案 1 :(得分:0)

您需要包含作曲家的自动加载器:

require __DIR__ . '/vendor/autoload.php';

您可以阅读文档here