|
Good Sphere posted:Thanks for the suggestions. They got Kamatera Ubuntu server with nginx. I logged into Kamatera's dashboard for the account, and ssh'd in Mac OS's Terminal. I don't know where to even start. I'm so used to using an ftp client and the like, and I don't even know how with this yet, or if I should. A new frontier for me. If you can SSH you can usually SFTP. Just connect with your FTP client of choice on port 22.
|
# ? Apr 14, 2020 19:10 |
|
|
# ? Jun 3, 2024 12:34 |
|
Pile Of Garbage posted:If you can SSH you can usually SFTP. Just connect with your FTP client of choice on port 22. Oh duh I wasn't using the right username. Thank you!
|
# ? Apr 14, 2020 19:39 |
|
What sqlsrv fetch command do I need to use for json data? The query i am using is code:
I want to use the results to populate a highchart table. Ive tried both fetch_array and object. When I use echo to populate the highchart data values.
|
# ? Apr 24, 2020 23:13 |
|
I'm not a PHP toucher by trade, but I've ended up having to debug some stuff written in PHP and have a hopefully quick and stupid question: Given copy('some/relative/path', 'destination'), what's the source path relative to? Because I would expect either __FILE__ or $PWD, but the way this thing is behaving it doesn't seem to be either of them -- the file containing the copy() call is in /srv/foo/plugins, $PWD is /srv/foo, and looking at strace(), the call to copy() is trying to read from the directory where index.php is installed (which is completely different, it's over in /nix/store). Is there some sort of implicit "document root" in PHP that it gets from the web server and is trying to read from?
|
# ? May 1, 2020 18:36 |
|
Wrap those filenames in realpath() to figure out where it thinks they should be. The path should be relative to the pwd, but you might not be where you think you are. Check getcwd() to make sure.
|
# ? May 2, 2020 03:02 |
|
joebuddah posted:What sqlsrv fetch command do I need to use for json data? I don’t understand. Are you asking how to import a JSON document into SQL Server? Or how to pull data from SQL Server as JSON to consume?
|
# ? May 2, 2020 17:38 |
|
SCP is another option for moving files around, syntax is widely used/copied so it's not a terrible tool to use, many systems come with it preinstalled Also if you want to get crazy, there's Magic Wormhole which is pretty neat, there's an easier-to-install version called Croc: https://github.com/schollz/croc I agree with the other guy, get that poo poo on AWS, it's easier to administrate + looks good on your resume
|
# ? May 3, 2020 20:40 |
|
Can someone help me with a check to see if a row is complete? I have a file of tab separated values, and some rows are incomplete, which breaks my processing. How can I check to see if the row is incomplete so I can do something else with it? code:
|
# ? May 5, 2020 04:58 |
|
Style question. I generally do procedures like this code:
code:
code:
code:
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- Agrikk posted:Can someone help me with a check to see if a row is complete? other than comparing the value to null? I figure there are 9 ways to do it simply by following what seems to make more sense, but you need a more advanced answer (with Regex maybe?) that I can't provide
|
# ? May 5, 2020 08:25 |
|
After a second through. Is better to pass the id instead of the object, so the caller don't need to know about things he can live withouth knowing. And because is good for code to be lazy and pass the buck to other code. The caller would need to do extra work.
|
# ? May 5, 2020 08:32 |
|
It depends on what it's doing with the information and what other things will need to do that. If the caller doesn't even have it as an object then yeah, I don't bother creating it just to pass it for the callee to just pull that single value back out.Agrikk posted:Can someone help me with a check to see if a row is complete? If you don't want to iterate over the pieces then you'll need a regex. Something like preg_match('/([^\t]+(\t|$)){4}/', $line, $output);
|
# ? May 5, 2020 15:13 |
|
Are there any major security issues with the latest version of PHP 7.0? I see that 7.2 exists, but I'm not sure if the current software I'm running will work with it, and I'd rather not risk breaking anything if there's no security issues. I can find security flaws doing a search on Google but I don't know which have been patched and which are still out there.
|
# ? Jun 3, 2020 22:12 |
|
https://www.php.net/supported-versions.php 7.0 is EOL'd. I'd say upgrade to 7.4
|
# ? Jun 3, 2020 22:36 |
|
Well crap, will do. I might have to do 7.2 though, it looks like the Amazon Linux version I'm using only has 7.2 from the package options I remember. I'll just take a snapshot of the instance and roll it back if it fails.
|
# ? Jun 4, 2020 00:04 |
|
22 Eargesplitten posted:Well crap, will do. I might have to do 7.2 though, it looks like the Amazon Linux version I'm using only has 7.2 from the package options I remember. I'll just take a snapshot of the instance and roll it back if it fails. At the very least 7.2 has a few months left and isn't long-dead levels of EOL.
|
# ? Jun 4, 2020 05:23 |
|
22 Eargesplitten posted:Are there any major security issues with the latest version of PHP 7.0? I see that 7.2 exists, but I'm not sure if the current software I'm running will work with it, and I'd rather not risk breaking anything if there's no security issues. I can find security flaws doing a search on Google but I don't know which have been patched and which are still out there. https://github.com/PHPCompatibility/PHPCompatibility is a good library to help alleviate some of the pain of upgrading PHP versions.
|
# ? Jun 6, 2020 04:18 |
|
Agrikk posted:Can someone help me with a check to see if a row is complete? I'm assuming you're using some combination of explode to break out the values; in that case you could just... check if they're broken before processing: php:<?php $data = "a\tb\tc\n\tb\tc\na\tb\na\tb\tc\n"; $a = explode("\n", $data); foreach ($a as $l) { $la = explode("\t", $a); if (count($la) < 3 || $la[0] == "" || $la[1] == "" || $la[2] == "") { // do something else with this line, which sucks and is broken continue; } // do what you do for normal lines } Tei posted:After a second through. Is better to pass the id instead of the object, so the caller don't need to know about things he can live withouth knowing. Given a choice between "public function doThingWithBar(\Bar $bar)" and "public function doThingWithBarId($id)" I'd say you should prefer the former in all cases if only because it guards against something that isn't a Bar id getting in there. There's other value, but that's the easiest one to explain.
|
# ? Jun 6, 2020 18:49 |
|
rt4 posted:Use any VPS you like. Check AwfulMart for some decent hosts with goon discounts. Also this is way, way late, but as someone who has written several long-running processes (some that have been running for multiple months and in one case literal years): php isn't really any worse than anything else for running long-running processes, it's just that the way you build a long-running task is a lot different than the way you write normal ones.
|
# ? Jun 6, 2020 18:52 |
|
Zamujasa posted:Also this is way, way late, but as someone who has written several long-running processes (some that have been running for multiple months and in one case literal years): php isn't really any worse than anything else for running long-running processes, it's just that the way you build a long-running task is a lot different than the way you write normal ones. I have quite a few PHP "workers" (that read off redis queues), and I don't see it being much different than node. You just have some kind of forked off child or blocking loop most of the time, instead of a top-down render resulting in stdout (to a page) It is bizarre to start with though, as someone explicitly used to writing PHP as a "page"
|
# ? Jun 6, 2020 19:22 |
|
Zamujasa posted:Given a choice between "public function doThingWithBar(\Bar $bar)" and "public function doThingWithBarId($id)" I'd say you should prefer the former in all cases if only because it guards against something that isn't a Bar id getting in there. I like this argument.
|
# ? Jun 8, 2020 14:32 |
|
Biowarfare posted:I have quite a few PHP "workers" (that read off redis queues), and I don't see it being much different than node. You just have some kind of forked off child or blocking loop most of the time, instead of a top-down render resulting in stdout (to a page) I have a few that poll a database (someone else's bad decision) every second and write to some network ports, as well as another set that acts as a server/translator for some networked devices. Reads input, translates it into usable data, then pushes it out to other endpoints. Both of these tend to run for months if left undisturbed, and the only reason they don't last longer is because "make them recover from network errors" has never been in the time budget I like php just because it's easy to get started with and there's no gigantic pile of dependencies or requirements just to begin. Most of it is either just built in or in one of the typically-bundled extensions. You don't need to import 20 modules just to get printf. (I say this, then I was reviewing a new hire's 'code challenge' which involved 200 MB of php and node modules for what took about 30 lines of raw PHP )
|
# ? Jun 10, 2020 21:59 |
|
I'm having a hard time passing an array of values via POST. Now you might say "wow you're dumb" and maybe I am, but let me explain. I am using jQuery on a page to add some additional rows to a table within a form that gets submitted, the number of rows needs to be dynamic and reloading the page and adding it via php isn't an option as there's some pretty heavy lifting being done on this page and it would take 5-10 seconds each time they wanted to add a new input field. So I've worked around this by using jQuery. Why jQuery you ask? This has to run in old as balls browsers so I can't use something else. Here is the situation so far. When I post it will pass the value in the first row of the table, naturally this row exists within the hard coded PHP as it's the reference row. I'm adding additional rows into the DOM using this handy little script: code:
Is it that a POST won't pick up these fields that are added using jQuery or are they just not formatted properly? The hardcoded row looks like this in my html file: code:
Please, any assistance would be hugely helpful as this project is due by EOD Sunday and this is really my last blocker before I submit it for client approval.
|
# ? Jun 27, 2020 04:29 |
|
Hello Mode6, It works for me when using the code you posted. So maybe the issue is somewhere else?
|
# ? Jun 27, 2020 07:53 |
|
Banditu posted:Hello Mode6, Hm. Ok interesting. How are you picking it up in the $_POST on the receiving page?
|
# ? Jun 27, 2020 14:14 |
|
To check the value I just used print_r :php:<?php print_r($_POST['additional_items']); ?>
|
# ? Jun 27, 2020 14:20 |
|
Banditu posted:To check the value I just used print_r : Awesome. I've been checking it the same way and only getting one of the values. Something fishy going on with this. Edit: turns out I'm just bad at html and had two opening body tags which may or may not have been causing it not to work. Removed the additional body tags and made the form tag outside the table instead of inside and now it works. Not sure which is the reason but it works. Thanks for validating that it was a me issue not a code issue. Really helped. ModeSix fucked around with this message at 14:47 on Jun 27, 2020 |
# ? Jun 27, 2020 14:34 |
|
The moment you are concatenating strings to make html in javascript,. is the moment you need to bring a simple template engine, like mustache (imo). It may be overblow at first, but if the code grown, it will grown into something that will make that grown easy to understand and under control.
|
# ? Jul 31, 2020 08:22 |
|
This might be better off asked in the SQL/database threads but I'll try here first. Let's say I've built a todo/task tracking application. I now want to add the ability to have scheduled or recurring tasks and I'm not sure how to model this in the database or how to implement this in the backend. On the front end it would basically allow a user to do the following: - Schedule a task into the future one time - Repeat tasks every __ days - Repeat a task every week on a specific day - Repeat a task every month on a specific day or the first/second/etc day/week of the month These are non-technical users so asking for a cron statement isn't going to work. How would I model this in the database and consume it?
|
# ? Dec 2, 2020 19:57 |
|
kiwid posted:This might be better off asked in the SQL/database threads but I'll try here first. I think you can do with something like this: - record the last time the task was executed - flags for whatever repetition types you need (make sense to allow to combine many types, like "every monday for 30 days") - flag for completed (aka "stop any type of repeated execution") - (optional) you may need some counters if your repetition is something like "repeat for 88 days" you do this code:
Tei fucked around with this message at 22:01 on Dec 2, 2020 |
# ? Dec 2, 2020 21:56 |
|
Tei posted:I think you can do with something like this: Thanks, after looking into it further it looks like this is called RRULE and there are libs out there to make this easier: https://github.com/rlanvin/php-rrule
|
# ? Dec 2, 2020 22:07 |
|
kiwid posted:Thanks, after looking into it further it looks like this is called RRULE and there are libs out there to make this easier: https://github.com/rlanvin/php-rrule cool!, using something already made is perfect and a good practice I build something like this years ago, but is cool that theres a library now. If I have to do something like this again I will use this library or one like it
|
# ? Dec 2, 2020 22:21 |
|
I have a very particular issue I am trying to tackle with string sorting and I've got it 80% of the way there. Let's say I've got 5 strings as follows: 2 for 1 - 6" Apple Pies 2 for 1 - 12" Apple Pies 50% Off - Banana Cakes 50% Off - 30 Carrot Cakes 2 For 1 - Dead Thing 2 for 1 - 5 Zebra Skins Right now I can get them to sort like this: 50% off - Banana Cakes 2 for 1 - Dead Thing 2 for 1 - 6" Apple Pies 2 for 1 - 12" Apple Pies 50% Off - 30 Carrot Cakes 2 for 1 - 5 Zebra Skins But ideally I'd like them to be sortable in alphabetical order, then by quantity/size if there is one as shown in the top list. Taking into account that 6 is before 12 (as we all know numbering in php is a pain). I've gotten it most of the way there using explodes, substrings etc. but I can't figure out how to merge with leading numbers, without leading numbers together to get a pure alphabetical, then size/quantity list. If someone can point me in the right direction on thi it would be super helpful. My spaghetti mess looks like this right now: code:
|
# ? Dec 17, 2020 23:58 |
|
Rather than trying to fudge everything into a string comparison, just do the actual comparison you want inside your compare function:code:
|
# ? Dec 18, 2020 00:15 |
|
Does anyone have any recommendations for creating a REST API that is backed by an existing MySQL database? I've taken a look at Lumen, but honestly I can't figuring the routing on it, even though syntactically it looks almost exactly like creating a REST API in NodeJS(Express). The documentation on Lumen is so poor I can't figure out to get it to work. ModeSix fucked around with this message at 04:27 on Jan 7, 2021 |
# ? Jan 7, 2021 04:18 |
|
ModeSix posted:Does anyone have any recommendations for creating a REST API that is backed by an existing MySQL database? How robust does it need to be? Is this just a couple of endpoints? If so, any modern framework (Symfony, Laravel) will allow you to set one up very easily, provide serializers and normalizers to convert your data to/from one format to another. If it needs to be very robust, really respect HATEOS, HTTP, REST, etc then you may want to look into API Platform: https://api-platform.com/
|
# ? Jan 7, 2021 11:56 |
|
musclecoder posted:How robust does it need to be? Is this just a couple of endpoints? If so, any modern framework (Symfony, Laravel) will allow you to set one up very easily, provide serializers and normalizers to convert your data to/from one format to another. If it needs to be very robust, really respect HATEOS, HTTP, REST, etc then you may want to look into API Platform: https://api-platform.com/ It's going to be pretty simple, using it to generate endpoints for a mobile application that needs access to some site/user data from the main site and doing direct DB calls is a no-no for many reasons. I just need to get some responses from some joins off the database, be able to put updates and validate auth. Simple is all I need. I'll take a look at Symfony, I think Lumen uses it in there because I was getting some good errors off of it that referenced Symfony.
|
# ? Jan 7, 2021 14:31 |
|
ModeSix posted:It's going to be pretty simple, using it to generate endpoints for a mobile application that needs access to some site/user data from the main site and doing direct DB calls is a no-no for many reasons. I just need to get some responses from some joins off the database, be able to put updates and validate auth. Simple is all I need. Yeah I'd stick with a basic straightforward Symfony application. Controllers can be as simple as: php:<? class ApiController { public function getSomeData(Request $request, Serializer $serializer) { $data = $entityManager->getRepository(Data::class)->findBy([ 'someAttribute' => 'someValue' ]); return JsonResponse::create($serializer->serialize($data)); } } ?>
|
# ? Jan 7, 2021 17:47 |
|
You could probably use this to automate the entire thing https://github.com/mevdschee/php-crud-api
|
# ? Jan 7, 2021 17:52 |
|
rt4 posted:You could probably use this to automate the entire thing This looks like exactly what I am looking for. Brilliant, thanks!
|
# ? Jan 7, 2021 20:17 |
|
|
# ? Jun 3, 2024 12:34 |
|
I am bashing my head in over this one. I am trying to install the php_yaml.dll extension on my windows server (Server 2019 Datacenter v1809) with PHP version 7.0.21 (Thread Safety: Enabled) and I am getting the following error when running php.exe from the command line: "Warning: PHP Startup: Unable to load dynamic library 'c:\php\ext\php_yaml.dll' - The specified module could not be found." I have other extensions in the exact same place (c:\php\ext) being accessed the same way (extension=<module>.dll) in c:\PHP\php.ini. I have tested the configuration settings in PHP.ini by renaming an active .dll file which immediately causes the same "Unable to load dynamic library" to show up, so I know the settings are pointing to the right places. For some reason PHP can't see php_yaml.dll. I have tried php_yaml-2.0.4-7.0-nts-vc14-x64 and php_yaml-2.0.4-7.0-ts-vc14-x64 and php_yaml-2.0.4-7.1-ts-vc14-x64 and they all behave the same way. I even tried php_yaml-2.2.1-7.4-ts-vc15-x64 and got a different error about "the procedure entry point" couldn't be located, which I'm sure has to do with the wrong version of VC14 vs VC15, but at least I know that PHP is looking in the right place for the file. So why cant PHP find php_yaml.dll?
|
# ? Jan 27, 2021 07:28 |