質問編集履歴
1
進展があったので、付随する質問
test
CHANGED
File without changes
|
test
CHANGED
@@ -241,3 +241,375 @@
|
|
241
241
|
#蛇足
|
242
242
|
|
243
243
|
`laravel`については`laracast`の英語のチュートリアル動画を頑張って観てみてます。それだけだと苦しいので`laravel 5.1`の分厚い本を買いましたが、バージョンの違いで割りと役に立たず、「出版されてる一番マシだと思われる本でもこの状態か」と納得することで逆に精神安定剤になっています。後はググるか`teratail`先生に頼るかなので、今にも心折れそうになりながら勉強してます。応援よろしくお願いします。
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
---
|
248
|
+
|
249
|
+
# 追記 (2017.7.16 18:17)
|
250
|
+
|
251
|
+
まず、上手く行ってる `MAMP`でどう見えるかを確認しておきたいと思います。
|
252
|
+
|
253
|
+
ブラウザで`http://localhost/maxiGos/`を表示させると、
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
![MAMP](d7fc493704f0a66af8813ef1e34c9cf1.png)
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
こんな感じに表示されます。デフォルトで選ばれる木目の碁盤が表示されることが分かると思います。
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
## とにかく laravel で碁盤を表示させる
|
266
|
+
|
267
|
+
次の目標は`http://maxigos.dev/maxiGos`で同様に碁盤が表示されることです。
|
268
|
+
|
269
|
+
`laravel`が`gosLib.php`の場所を知らないのかと思い、`route/web.php`を色々と試していたのですがそれは辞め、`sgfplayer.php`の4行目の
|
270
|
+
|
271
|
+
```php
|
272
|
+
|
273
|
+
include_once("../_php/gosLib.php");
|
274
|
+
|
275
|
+
```
|
276
|
+
|
277
|
+
を
|
278
|
+
|
279
|
+
```php
|
280
|
+
|
281
|
+
include_once("_maxiGos/_php/gosLib.php");
|
282
|
+
|
283
|
+
```
|
284
|
+
|
285
|
+
と書き換えてあげました。
|
286
|
+
|
287
|
+
これでも碁盤は表示されないのですが、
|
288
|
+
|
289
|
+
`http://maxigos.dev/_maxigos/_mgos/sgfplayer.php`
|
290
|
+
|
291
|
+
を見ると、
|
292
|
+
|
293
|
+
```
|
294
|
+
|
295
|
+
Whoops, looks like something went wrong.
|
296
|
+
|
297
|
+
(1/1) ErrorException
|
298
|
+
|
299
|
+
include(_sample/neo-classic/_cfg/basic.cfg): failed to open stream: No such file or directory
|
300
|
+
|
301
|
+
in gosLib.php (line 60)
|
302
|
+
|
303
|
+
```
|
304
|
+
|
305
|
+
とエラーが表示されました。これで`gosLib.php`が見えたことが確認できました。
|
306
|
+
|
307
|
+
その60行目というのが
|
308
|
+
|
309
|
+
```php
|
310
|
+
|
311
|
+
else include($gosRootRelativePath."_sample/neo-classic/_cfg/basic.cfg");
|
312
|
+
|
313
|
+
```
|
314
|
+
|
315
|
+
であったので、試しにその前に
|
316
|
+
|
317
|
+
```php
|
318
|
+
|
319
|
+
dd($gosRootRelativePath);
|
320
|
+
|
321
|
+
```
|
322
|
+
|
323
|
+
を挿入してみると、長い`javascript`と思われるソースのようなものの最後の方に
|
324
|
+
|
325
|
+
```html
|
326
|
+
|
327
|
+
<span class=sf-dump-const>null</span>
|
328
|
+
|
329
|
+
```
|
330
|
+
|
331
|
+
と記述されていました。そこで、上の`dd`の前に
|
332
|
+
|
333
|
+
```php
|
334
|
+
|
335
|
+
$gosRootRelativePath = '_maxiGos/';
|
336
|
+
|
337
|
+
```
|
338
|
+
|
339
|
+
と明示的に代入してやったところ、
|
340
|
+
|
341
|
+
```html
|
342
|
+
|
343
|
+
<span class=sf-dump-str title="9 characters">_maxiGos/</span>
|
344
|
+
|
345
|
+
```
|
346
|
+
|
347
|
+
に変わりました。
|
348
|
+
|
349
|
+
この状態でブラウザをリロードすると、ついに
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
![laravel](44489e3ef776749f12926efd649b4201.png)
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
と碁盤が表示されました。
|
358
|
+
|
359
|
+
大進歩です。
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
Q1) `sgfplayer.php`の4行目、`_maxiGox/`が`../`ではいけないのは何故でしょう?
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
## 碁盤が白黒(木目じゃない)のは?
|
368
|
+
|
369
|
+
見てお分かりのように、`MAMP`だと木目調なのですが、`laravel`では白黒です。
|
370
|
+
|
371
|
+
`http://maxigos.dev/_maxigos/_mgos/sgfplayer.php`
|
372
|
+
|
373
|
+
のはき出す`javascript`の中に
|
374
|
+
|
375
|
+
```javascript
|
376
|
+
|
377
|
+
mxG.AddCss("_sample/neo-classic/_css/basic.css");
|
378
|
+
|
379
|
+
```
|
380
|
+
|
381
|
+
とあるので、
|
382
|
+
|
383
|
+
`http://maxigos.dev/_maxigos/_sample/neo-classic/_css/_common.css`
|
384
|
+
|
385
|
+
を見てみると、
|
386
|
+
|
387
|
+
```css
|
388
|
+
|
389
|
+
div.mxNeoClassicGlobalBoxDiv div.mxGobanDiv canvas
|
390
|
+
|
391
|
+
{
|
392
|
+
|
393
|
+
background-image:url(../../../_img/bk/beech.jpg);background-size:cover;
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
```
|
398
|
+
|
399
|
+
という一節が出てきます。「そうか」と、要は`laravel`は相対親ディレクトリ`../`が苦手なのかと思い、ってことは、
|
400
|
+
|
401
|
+
`http://maxigos.dev/_maxigos/_sample/neo-classic/_css/../../../_img/bk/beech.jpg`
|
402
|
+
|
403
|
+
をみようとしてもダメなのねと思いながら見てみたら、なんと木目の画像が表示されました。
|
404
|
+
|
405
|
+
ちゃんと
|
406
|
+
|
407
|
+
`http://maxigos.dev/_maxigos/_img/bk/beech.jpg`
|
408
|
+
|
409
|
+
にリダイレクト(?)されていました。
|
410
|
+
|
411
|
+
とても意外でした。
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
Q2) `laravel`では相対親ディレクトリ指定が難しいという解釈は間違ってるのでしょうか?
|
416
|
+
|
417
|
+
Q3) 順番に見ていったら画像が表示されたのに、何故`http://maxigos.dev/_maxigos/`では碁盤の背景に木目画像が表示されないのでしょうか?
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
## 話は前後しますが、インクルードされる path.php というファイルについて
|
422
|
+
|
423
|
+
`http://maxigos.dev/_maxigos/_mgos/sgfplayer.php`
|
424
|
+
|
425
|
+
を見ると、
|
426
|
+
|
427
|
+
```
|
428
|
+
|
429
|
+
Whoops, looks like something went wrong.
|
430
|
+
|
431
|
+
(1/1) ErrorException
|
432
|
+
|
433
|
+
include(_sample/neo-classic/_cfg/basic.cfg): failed to open stream: No such file or directory
|
434
|
+
|
435
|
+
in gosLib.php (line 60)
|
436
|
+
|
437
|
+
```
|
438
|
+
|
439
|
+
となるのは、`gosLib.php`が最初に`include_once`してる`path.php`というファイルの終わりで
|
440
|
+
|
441
|
+
```php
|
442
|
+
|
443
|
+
// 1) relative path (in theory, used in .php files)
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
if (!isset($gosRootRelativePath)) $gosRootRelativePath=gosGetRootRelativePath();
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
// 2) absolute path (in theory, used in .js files)
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
if (!isset($gosRootAbsolutePath)) $gosRootAbsolutePath=gosGetRootAbsolutePath();
|
456
|
+
|
457
|
+
```
|
458
|
+
|
459
|
+
とているのですが、それに続いて
|
460
|
+
|
461
|
+
```php
|
462
|
+
|
463
|
+
dd($gosRootRelativePath);
|
464
|
+
|
465
|
+
```
|
466
|
+
|
467
|
+
とすると、
|
468
|
+
|
469
|
+
`"../../Users/taro/development/laravel/maxiGos/public/_maxiGos/"`
|
470
|
+
|
471
|
+
```php
|
472
|
+
|
473
|
+
dd($gosRootAbsolutePath);
|
474
|
+
|
475
|
+
```
|
476
|
+
|
477
|
+
とすると、
|
478
|
+
|
479
|
+
`"http://maxigos.dev/Users/taro/development/laravel/maxiGos/public/_maxiGos/"`
|
480
|
+
|
481
|
+
と、明らかに意図しない値が帰って来てます。
|
482
|
+
|
483
|
+
(見易さのため、一旦`sgfplayer.php`の`header()`関数はコメントアウトしてあります)
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
Q4) `MAMP`では上手く動いてるようにみえるこのファイルが`laravel`では意図せぬ動きに見えるのはなぜでしょう?
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
一応`path.php`の全文を載せておきます。
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
```php
|
496
|
+
|
497
|
+
<?php
|
498
|
+
|
499
|
+
// maxiGos v6.57 > path.php
|
500
|
+
|
501
|
+
// must be in the same folder as aloneLib.php and gosLib.php
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
// $gosRootRelativePath is a relative path from php script that includes this script
|
506
|
+
|
507
|
+
// to "_maxigos" folder (must end by "_maxigos/" or be "/")
|
508
|
+
|
509
|
+
// $gosRootRelativePath can also be set in the calling php script of the web page that uses maxiGos
|
510
|
+
|
511
|
+
// better to use a relative path (to the calling php scripts) to avoid access file problem
|
512
|
+
|
513
|
+
// sometimes, it may be necessary to set it by hand in the php calling scripts
|
514
|
+
|
515
|
+
// when gosGetRootPath() doesn't work (for instance when $_SERVER['DOCUMENT_ROOT'] is unkown)
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
// $gosRootAbsolutePath is an absolute web path to "_maxigos" folder (ends by "_maxigos/")
|
520
|
+
|
521
|
+
// it is used in maxiGos ".js" code to retrieve external resources such as css files, images, ...
|
522
|
+
|
523
|
+
// warning: some servers seem to add "/" to the end of $_SERVER['DOCUMENT_ROOT'], some others don't
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
function gosGetRootRelativePath()
|
528
|
+
|
529
|
+
{
|
530
|
+
|
531
|
+
$a=$_SERVER['PHP_SELF'];
|
532
|
+
|
533
|
+
$thisDir=substr(dirname(__FILE__),strlen($_SERVER['DOCUMENT_ROOT']));
|
534
|
+
|
535
|
+
$len=strlen($thisDir);
|
536
|
+
|
537
|
+
$gosDir=substr($thisDir,0,$len-5); // -5 to remove "/_php"
|
538
|
+
|
539
|
+
$b=$gosDir."/";
|
540
|
+
|
541
|
+
$k=0;
|
542
|
+
|
543
|
+
$c="";
|
544
|
+
|
545
|
+
$km=substr_count($a,"/")-1;
|
546
|
+
|
547
|
+
while($k<$km)
|
548
|
+
|
549
|
+
{
|
550
|
+
|
551
|
+
$c=$c."../";
|
552
|
+
|
553
|
+
$k++;
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
return $c.preg_replace("#^[/]+?#","",$b);
|
558
|
+
|
559
|
+
}
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
function gosGetRootAbsolutePath()
|
564
|
+
|
565
|
+
{
|
566
|
+
|
567
|
+
$thisDir=substr(dirname(__FILE__),strlen($_SERVER['DOCUMENT_ROOT']));
|
568
|
+
|
569
|
+
$len=strlen($thisDir);
|
570
|
+
|
571
|
+
$gosDir=substr($thisDir,0,$len-5); // -5 to remove "/_php"
|
572
|
+
|
573
|
+
$gosDir="/".preg_replace("#^[/]+?#","",$gosDir);
|
574
|
+
|
575
|
+
$gosDir=preg_replace("#[/]+?$#","",$gosDir)."/";
|
576
|
+
|
577
|
+
if (isset($_SERVER['HTTP_HOST']))
|
578
|
+
|
579
|
+
{
|
580
|
+
|
581
|
+
// add protocol and host name
|
582
|
+
|
583
|
+
// useful when maxiGos is on a server different from the calling page one
|
584
|
+
|
585
|
+
$protocol=stripos($_SERVER['SERVER_PROTOCOL'],'https')===true ?'https://':'http://';
|
586
|
+
|
587
|
+
$gosDir=$protocol.$_SERVER['HTTP_HOST'].$gosDir;
|
588
|
+
|
589
|
+
}
|
590
|
+
|
591
|
+
return $gosDir;
|
592
|
+
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
// 1) relative path (in theory, used in .php files)
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
if (!isset($gosRootRelativePath)) $gosRootRelativePath=gosGetRootRelativePath();
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
// 2) absolute path (in theory, used in .js files)
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
if (!isset($gosRootAbsolutePath)) $gosRootAbsolutePath=gosGetRootAbsolutePath();
|
610
|
+
|
611
|
+
```
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
以上、よろしくお願いします。
|