Jump to content

maxxd

Gurus
  • Posts

    1,659
  • Joined

  • Last visited

  • Days Won

    52

Posts posted by maxxd

  1. As far as I can tell, it's good. Nice thing for me is BitBucket offers unlimited free private repositories with up to (I believe - it's been a while since I checked) 5 contributors per repository. So for a small team or independent developer with friends, totally free forever. And SourceTree is free no matter what - you can use as many different accounts on as many different repository hosts as you want - BitBucket, GitHub, GitLabs, or Azure.

    Good lord, I should get a commission. Of course, a commission on free is pretty much what I'm already getting, so there ya' go.

    • Like 1
  2. Beyond that, your code makes almost no semantic sense. $class indicates the value is a class name, but you're using it in an href attribute. $url should contain, well, a URL. You're using it in a href tel attribute (as requinix points out, twice). Make maintenance easier on yourself and try make variable names make some sort of sense given the data they're expected to contain.

  3. If your PHP is also about 8 years old, it's going to need to be redone anyway, and probably sooner rather than later. I'd recommend pushing the site live when the e-commerce part is done, tested, and validated/verified. Then use a strangler fig pattern to iterate on the code, refactoring and replacing bits and pieces as you go. You can make changes to the HTML (PHP output, whatever) and CSS without touching the PHP. You could even start ripping out procedural code and converting to a more modern, extendable and maintainable code-base.

  4. If your code is well thought out to begin with, making it responsive is CSS-based and shouldn't be that big a deal in the grand scheme of things; in other words, it shouldn't touch your php much or at all. It may require some rethink on your html, but even then that should be pretty minimal.

    If you've got a ton of inline styles well, that's a different story, but you'll eventually have to redo the site to fix that anyway...

    So basically, as long as the functionality is complete and tested, push to production now and start refactoring right after that.

  5. Wordpress can handle custom tables, but it doesn't like it. If you're using ACF you can create arrays of data - honestly, even when I was dealing with WP daily I never used ACF, but I knew a lot of people that did. I think it's called a 'repeater' - check this: https://www.advancedcustomfields.com/resources/code-examples/. Doing this will negate the need to append a number to the variable name, and allows you to use count() to do what you're looking to do. It also allows you to not loop exactly five times regardless the amount of data present, and to track a grave with more than 5 bodies.

  6. In my experience, VSCode is not at all buggy; I've used PHPStorm and - personally - didn't like the project setup aspect of things. That having been said, I have to say that setting up a debugger is much easier with PHPStorm than VSCode, and all of my co-workers use PHPStorm and love it. So honestly, check out some plugins, give both a fair shake, and use what helps you get the work done.

    As for the code using ajax on page load, it kinda depends. Is this a page that you're gathering analytics or is it reliant on search engine rankings? If so, you're probably going to want to have content available when the page loads. If it's part of an SPA after the user has logged in, then you can do a fetch on page load. Or you can server-side render the initial page content, then use ajax or fetch to update and/or change that data depending on the user action.

    • Like 1
  7. 13 minutes ago, JoshEir said:

    Someone said PHP takes 6 months to learn.

    I've been coding PHP for about 20 years now - version 4 was just about to come out when I started. Most of that time was professional (I was lucky enough to have a job that paid me to learn while I worked at first). To this day, I learn something new every day, either while taking on a problem at work or coming here.

    Don't expect to be able to put a timer on when you "know" php. Get proficient with the language but more importantly understand programming. If you've committed to coding, read "The Pragmatic Programmer" by Andy Hunt and Dave Thomas, and "Design Patterns" by the Gang of Four. For a php specific viewpoint, check out "PHP Objects, Patterns, and Practices" by Matt Zandstra. There are other resources I'm sure more will chime in with, but those are three that I go back to regularly.

    There are online sources that are very good, but there are also online resources that are very bad, and it's often difficult to tell which is which. While you're doing tutorials, check in here - this is a great place to get good advice from seasoned professionals.

  8. So, as @benanamen pointed out above, the code you posted is incomplete and "I keep getting errors when I try to change it" isn't nearly specific enough to help us to help you debug. In addition, Google Chrome developer tools won't cause errors - they will report them (depending on the error type); depending on which tab you're on, those errors may be server-side (php) or they may be client-side(JavaScript). You'll have to tell us what the error is and which tab in the tools is reporting it.

    As far as the comment about prepared statements, again benanamen is correct - check out these links:

    https://www.php.net/manual/en/pdo.prepared-statements.php

    https://www.php.net/manual/en/pdo.prepare.php

    • Like 1
  9. There's no AJAX in anything you just posted. I'm also assuming that's an example because there's nothing there that JavaScript alone couldn't handle on its own. The PHP will parse the call to myphpfunction() on the server before the page gets sent to the browser - the JavaScript will be this:

    <script type="text/javascript">
        alert("The sum is: 360");
    </script>

    If that's all you need, that's fine. If you need to call myphpfunction() with different values based on a user selection and you don't want to reload the entire page, you're going to have to use JavaScript and AJAX.

    • Like 1
  10. You don't need jQuery to run AJAX, you just need JavaScript. So, either go modern with fetch or use XMLHttpRequest (or ActiveXObject). If you want to make multiple AJAX calls from the same page, nothing's stopping you - pick a trigger and call a different PHP target for the request. If you want to get tricky, pass an 'action' parameter to your PHP and decide the action to run based on that - 

    let resp = fetch(url, {
    	method: 'get',
    	body: JSON.stringify({
    		'action': 'doSomething',
    		'data': ['data','more','etc']
    	})
    });

     

    function doSomething(){
    	switch($_GET['action']){
    		case 'doSomething':
    			doSomething($_GET['data']);
    		break;
    		case 'doSomethingElse':
    			doSomethingElse($_GET['data']);
    		break;
    	}
    }

    (not tested code, just a basic idea)

    • Like 1
  11. Hi all.

    Does anyone use Localstack to for local AWS development? I'm currently developing on a system that uses numerous AWS SQS queues, AWS ElasticSearch, AWS Redis, and many, many S3 buckets with about three dozen PHP-based micro-services; I've built a local development environment consisting of containers using several Docker images, one of which mocks AWS using a Localstack image. This works, for the most part, but I find that the Localstack instance just ... stops working. It - after a random amount of time, and intermittently if more often than not - won't process any of the queues that the system uses, or will drop bucket contents despite being set up for persistence (the `DATA_DIR` objective is set to `/tmp/localstack/data` as instructed in the README).

    I get the impression that Localstack is fairly widely used for local AWS development, so I have to assume if this was a normal situation I'd've found it in my searching, but so far it doesn't seem to be a big deal. I'll post the docker-compose file here if it helps, but does anyone have any experience with a similar situation and feel like sharing tips? Did it work, did it not, do I need to convince my company to pay for the pro version, do I need to do a modified rain dance, etc?

    As always, thanks in advance for any thoughts or advice.

  12. 6 hours ago, Barand said:

    Have you considered RTFM?

    I have, and it was a genuine question. I guess I've just been lucky enough to have never come across a situation where the distinction has bitten me in the butt or where I've noticed, in all honesty.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.