Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boilerplate code not working #56

Open
marcosdipaolo opened this issue Apr 18, 2019 · 3 comments
Open

Boilerplate code not working #56

marcosdipaolo opened this issue Apr 18, 2019 · 3 comments

Comments

@marcosdipaolo
Copy link

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
Copy link

peter279k commented Apr 18, 2019

@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
Copy link
Author

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
Copy link

peter279k commented May 7, 2021

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 :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants