yohang / CalendR

The missing PHP 5.3+ calendar management library.
http:/yohan.giarel.li/CalendR
MIT License
465 stars 65 forks source link

Boilerplate code not working #56

Open marcosdipaolo opened 5 years ago

marcosdipaolo commented 5 years ago

Is this app still working with php 7 and Laravel 5.8?

Because non of the site's bolierplate code is working.

I cannot biuld the calendar, it only renders the day names, Mon to Fri repeteadly.

thanks.

peter279k commented 5 years ago

@marcosdipaolo, thank you for your report.

Could you provide some build steps about this issue you mention?

It can help us to reproduce issue and help you to find the current problems.

BTW, I think this is the PHP package and it will be worked successfully in all frameworks.

marcosdipaolo commented 5 years ago

As i told you, the boiler plate code at the website doesn't provide a simple calendar, instead this comes out:

Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday

<?php
// Use the factory to get your period
$factory = new CalendR\Calendar;
$month = $factory->getMonth(2012, 01);
?>

<table>
    <?php // Iterate over your month and get weeks ?>
    <?php foreach ($month as $week): ?>
    <tr>
        <?php // Iterate over your month and get days ?>
        <?php foreach ($week as $day): ?>
            <?php //Check days that are out of your month ?>
            <td><?php echo $day ?></td>
        <?php endforeach ?>
    </tr>
    <?php endforeach ?>
</table>
peter279k commented 3 years ago

Hi @marcosdipaolo, sorry for my delay response. Please try this:

<?php require_once __DIR__ . '/vendor/autoload.php';  ?>
<?php $factory = new CalendR\Calendar;  ?>
<?php $month = $factory->getMonth(2012, 01) ?>

    <table>
    <?php // Iterate over your month and get weeks ?>
    <tr>
        <?php foreach (range(0, 6) as $index): ?>
        <th><?php echo ($month->getDays()[$index])->format('l'); ?></th>
        <?php endforeach ?>
    </tr>
    <?php for ($index=0; $index<count($month->getDays()); $index += 7): ?>
    <tr>
        <?php foreach (range(0, 6) as $number):  ?>
        <?php // Iterate over your month and get days ?>
        <?php if (($number + $index) >= count($month->getDays())) { break; } ?>
            <td><?php echo ($month->getDays()[$index+$number])->format('d'); ?></td>
        <?php endforeach ?>
    </tr>
    <?php endfor ?>
</table>

It seems that the boilerplate codes are not worked anymore. And I use alternative way to create the calendar (see above codes).

And it should be:

image

And just notice that I forked this repository to this repository.

Please submit issue on this issue URL if you've any other questions/issues :).