'PHP'에 해당되는 글 15건

  1. 2010.08.17 [PHP] MongoDB 사용하기
  2. 2010.08.17 [MongoDB] APM에서 시작하기
  3. 2010.07.20 FirePHP 사용법
  4. 2010.07.20 post raw data
  5. 2010.07.02 PHP 이미지 crop
Server-Side/PHP2010. 8. 17. 21:43
<?php
$mongoDB = new Mongo();
$newDB = $mongoDB->newDB;
$newCollection = $newDB->newCollection;

$doc = array('name' => 'owner', 'text' => 'this is test');
$newCollection->insert($doc);

$mongoDB->close();
?>

쉘에 들어가서 다음을 입력하면 확인가능하다.
>db.newCollection.find()

'Server-Side > PHP' 카테고리의 다른 글

[PHP] how to install memcached on Windows XP  (0) 2010.10.14
[PHP] 정규식으로 한글 영어 숫자 추출하기  (1) 2010.10.12
FirePHP 사용법  (0) 2010.07.20
post raw data  (0) 2010.07.20
PHP 이미지 crop  (0) 2010.07.02
Posted by 준피
Server-Side/MongoDB2010. 8. 17. 10:27
1. mongoDB 설치하기

2. 압축풀기
   본인은 C:\MongoDB 에 풀었다.

3. data 폴더 생성하기 (DB data를 위해 생성함)
   본인은 C:\MongoDB\data 에 생성함

4. MongoDB 시작
   
C:\MongoDB\bin> mongod --dbpath C:\MongoDB\data


5. php에서 쓸 MongoDB 드라이버설치
   다른버전 찾기 -> 여기

6. 압축풀고 PHP의 extension 폴더에 dll 파일을 넣음
   C:\APM_Setup\Server\PHP5\ext 폴더가 extension 폴더임
   (본인은 APM_Setup에 APM을 설치함)

7. php.ini에서 해당 모듈을 적용함
   php.ini에 보면 extension정보가 쭉 나열되어 있는 곳이 있음
   거기에 밑의 한줄을 추가해줌
   이왕이면 알파벳 순서에 맞게 하는게 나중에 찾기 편할 듯
 
extension=php_mongo.dll

8. 아파치 재시작
   APMSETUP Monitor를 열어서 Apache를 재시작한다.

9. 확인하기
   echo phpinfo(); 를 이용해서 불러온 정보에 mongo 관련 설정이 있는지 확인한다.
   설치 끝!


[테스트하기] - 반드시 "4번.몽고DB실행"을 한 뒤에 작업해야함.

<?php
$m = new Mongo();
?>


MongoDB를 실행하지 않으면 다음과 같은 에러를 볼 수 있다.

Fatal error: Uncaught exception 'MongoConnectionException' with message ': Unknown error' in C:\APM_Setup\htdocs\mongoDB_tester\index.php:4 Stack trace: #0 C:\APM_Setup\htdocs\mongoDB_tester\index.php(4): Mongo->__construct() #1 {main} thrown in C:\APM_Setup\htdocs\mongoDB_tester\index.php on line 4
 

[참고 사이트]


Posted by 준피
Server-Side/PHP2010. 7. 20. 15:43
require_once './library/FirePHP.class.php';
$firephp = FirePHP::getInstance(true);
$firephp->log($variable);

FirePHP 사용법.


'Server-Side > PHP' 카테고리의 다른 글

[PHP] 정규식으로 한글 영어 숫자 추출하기  (1) 2010.10.12
[PHP] MongoDB 사용하기  (0) 2010.08.17
post raw data  (0) 2010.07.20
PHP 이미지 crop  (0) 2010.07.02
PHP 파일업로드  (1) 2010.07.02
Posted by 준피
Server-Side/PHP2010. 7. 20. 13:51
file_get_contents("php://input");

POST 방식으로 보낸 http 패킷의 body에 접근할 수 있다.

일반적으로 PHP에서는 form방식 전송을 이용하는 경우가 대부분이지만

body에 JSON으로 만든 raw data를 넣어서 보내는 경우에 서버단에서 접근하려면

위와 같은 명령어를 이용해야 한다.

'Server-Side > PHP' 카테고리의 다른 글

[PHP] MongoDB 사용하기  (0) 2010.08.17
FirePHP 사용법  (0) 2010.07.20
PHP 이미지 crop  (0) 2010.07.02
PHP 파일업로드  (1) 2010.07.02
[Code Igniter] layout 적용하기  (0) 2010.04.23
Posted by 준피
Server-Side/PHP2010. 7. 2. 00:52
<iframe name="cropFrame" width="60" height="50" scrolling="no" style="display:none;"></iframe>
<form action="crop.php" method="post" target="cropFrame">
    <input id="imageSrc" type="hidden" name="imageSrc" value="" />
    <input id="x" type="hidden" name="x" value="0" />
    <input id="y" type="hidden" name="y" value="0" />
    <input id="w" type="hidden" name="w" value="450" />
    <input id="h" type="hidden" name="h" value="200" />
    <input type="submit" value="crop" />
</form>

----------------------------------------------------------------------

<?php
    require_once './FirePHPCore/FirePHP.class.php';
    $firephp = FirePHP::getInstance(true);

    //$firephp->log($_POST['imageSrc']);
    
    $imageSrc = $_POST['imageSrc'];
    $x = $_POST['x'];
    $y = $_POST['y'];
    $w = $_POST['w'];  // 높이
    $h = $_POST['h'];   // 길이

    $target_w = 450;
    $target_h = 200;
    $jpeg_quality = 90;
    $src = substr($imageSrc, 2);
    $img_r = imagecreatefromjpeg($src);
    $dst_r = ImageCreateTrueColor($w, $h);

    imagecopyresampled(
        $dst_r,
        $img_r,
        0, 0, $x, $y,
        $target_w, $target_h, $w, $h
    );

    $output_filename = './pic/test.jpg';

    header('Content-type: image/jpeg');
    imagejpeg($dst_r, $output_filename, $jpeg_quality);
?>

imagecreatefromjpeg($src);
 - 해당 경로의 파일을 jpeg 이미지로 생성함

ImageCreateTrueColor($w, $h);
 - 파라미터로 받은 넓이와 높이의 크기만한 검정색 이미지를 생성함

imagecopyresampled(
    $dst_r, // 타겟 이미지
    $img_r,  // 복사할 이미지
    0,         // 타겟 이미지의 x좌표
    0,         // 타겟 이미지의 y좌표
    $x,       // 원본 이미지의 x좌표
    $y,       // 원본 이미지의 y좌표
    $target_w, // 타겟 이미지의 넓이
    $target_h,  // 타겟 이미지의 높이
    $w,      // 원본 이미지의 넓이
    $h        // 원본 이미지의 높이
);
 - 이미지의 크기를 변경해서 복사함
 - 이미지의 x, y 좌표는 좌상단 모서리에서 시작함

'Server-Side > PHP' 카테고리의 다른 글

FirePHP 사용법  (0) 2010.07.20
post raw data  (0) 2010.07.20
PHP 파일업로드  (1) 2010.07.02
[Code Igniter] layout 적용하기  (0) 2010.04.23
PHP 시간함수( strtotime, time(), date() )  (0) 2010.03.25
Posted by 준피